Я пытаюсь получить свои удаленные push-уведомления для работы на моем телефоне. Когда я подключаю свой телефон к компьютеру и запускаю симулятор через свой телефон, уведомления, отправленные с консоли Firebase, отлично работают. Однако, когда я загрузил его на Testflight и загрузил его на свой телефон, мои push-уведомления не поступают.Firebase Push Notifications не работает на телефоне, но работает в симуляторе
Мои сертификаты загружены правильно и ниже мой код
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init() {
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerForRemoteNotifications()
application.registerUserNotificationSettings(notificationSettings)
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String?,
annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp()
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
fetchCompletionHandler completionHandler: (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
// Print message ID.
print("Message ID: \(userInfo["gcm.message_id"]!)")
// Print full message.
print("%@", userInfo)
completionHandler(.NoData)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(error)
print(error.description)
}
}
Вы могли протестировать push-уведомления с помощью производственных сертификатов? У меня такая же проблема. Ad-hoc-сборки не будут получать push-уведомления от firebase. – sleepwalkerfx
Кстати, ваш скриншот показывает только сертификаты разработки. Вы создали сертификаты производства SSL? – sleepwalkerfx