Archived
Push from command line
This commit is contained in:
+17
-56
@@ -19,25 +19,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
FirebaseApp.configure()
|
||||
|
||||
if #available(iOS 10.0, *) {
|
||||
// For iOS 10 display notification (sent via APNS)
|
||||
UNUserNotificationCenter.current().delegate = self
|
||||
|
||||
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
|
||||
UNUserNotificationCenter.current().requestAuthorization(
|
||||
options: authOptions,
|
||||
completionHandler: {_, _ in })
|
||||
} else {
|
||||
let settings: UIUserNotificationSettings =
|
||||
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
|
||||
application.registerUserNotificationSettings(settings)
|
||||
}
|
||||
// if #available(iOS 10.0, *) {
|
||||
// // For iOS 10 display notification (sent via APNS)
|
||||
// UNUserNotificationCenter.current().delegate = self
|
||||
//
|
||||
// let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
|
||||
// UNUserNotificationCenter.current().requestAuthorization(
|
||||
// options: authOptions,
|
||||
// completionHandler: {_, _ in })
|
||||
// } else {
|
||||
// let settings: UIUserNotificationSettings =
|
||||
// UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
|
||||
// application.registerUserNotificationSettings(settings)
|
||||
// }
|
||||
//
|
||||
// application.registerForRemoteNotifications()
|
||||
|
||||
application.registerForRemoteNotifications()
|
||||
|
||||
Messaging.messaging().subscribe(toTopic: "substitutions-ios") { error in
|
||||
print("Subscribed to substitutions topic")
|
||||
}
|
||||
Messaging.messaging().subscribe(toTopic: "substitutions-ios")
|
||||
Messaging.messaging().subscribe(toTopic: "substitutions-broadcast")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -62,43 +61,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
|
||||
// If you are receiving a notification message while your app is in the background,
|
||||
// this callback will not be fired till the user taps on the notification launching the application.
|
||||
// TODO: Handle data of notification
|
||||
|
||||
// With swizzling disabled you must let Messaging know about the message, for Analytics
|
||||
// Messaging.messaging().appDidReceiveMessage(userInfo)
|
||||
|
||||
// Print message ID.
|
||||
if let messageID = userInfo[gcmMessageIDKey] {
|
||||
print("Message ID: \(messageID)")
|
||||
}
|
||||
|
||||
// Print full message.
|
||||
print(userInfo)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
|
||||
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||
// If you are receiving a notification message while your app is in the background,
|
||||
// this callback will not be fired till the user taps on the notification launching the application.
|
||||
// TODO: Handle data of notification
|
||||
|
||||
// With swizzling disabled you must let Messaging know about the message, for Analytics
|
||||
// Messaging.messaging().appDidReceiveMessage(userInfo)
|
||||
|
||||
// Print message ID.
|
||||
if let messageID = userInfo[gcmMessageIDKey] {
|
||||
print("Message ID: \(messageID)")
|
||||
}
|
||||
|
||||
// Print full message.
|
||||
print(userInfo)
|
||||
|
||||
completionHandler(UIBackgroundFetchResult.newData)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user