Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 未接收从Firebase控制台发送的推送通知_Ios_Objective C_Firebase_Push Notification_Remote Notifications - Fatal编程技术网

Ios 未接收从Firebase控制台发送的推送通知

Ios 未接收从Firebase控制台发送的推送通知,ios,objective-c,firebase,push-notification,remote-notifications,Ios,Objective C,Firebase,Push Notification,Remote Notifications,从Firebase控制台发送的推送通知未显示。。昨天,当我删除我的应用程序并重新安装时,它们出现了——但只有一次,然后它们就不再出现了。今天他们一点也没有出现 我试图更新我的APNs证书,在Firebase上创建一个新的应用程序,运行examplecode,检查包标识符是否正确,检查xcode中的设置,现在我想不起来了 我能够接收来自APNs测试人员的推送通知,所以我很确定我的证书是好的!不知怎的,这一定是火基问题 这是我的appDelegate: class AppDelegate: UIRe

从Firebase控制台发送的推送通知未显示。。昨天,当我删除我的应用程序并重新安装时,它们出现了——但只有一次,然后它们就不再出现了。今天他们一点也没有出现

我试图更新我的APNs证书,在Firebase上创建一个新的应用程序,运行examplecode,检查包标识符是否正确,检查xcode中的设置,现在我想不起来了

我能够接收来自APNs测试人员的推送通知,所以我很确定我的证书是好的!不知怎的,这一定是火基问题

这是我的appDelegate:

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    UIApplication.sharedApplication().statusBarStyle = .Default
    // Parse
    User.initialize()
    PFCategory.initialize()
    Follow.initialize()
    Activity.initialize()
    PostElement.initialize()
    PFComment.initialize()
    Socials.initialize()
    Notification.initialize()

    let configuration = ParseClientConfiguration {
        $0.applicationId = "Agpq2y3O2Gxxxxxx"
        $0.clientKey = "k2bM8XTYf354fxAxxxxxxxxxx"
        $0.server = "https://parseapi.back4app.com/"
        $0.localDatastoreEnabled = false
    }
    Parse.initializeWithConfiguration(configuration)
    PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)

    // Firebase configuration
    FIRApp.configure()

    // Facebook
    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

    // Add observer for InstanceID token refresh callback.
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.tokenRefreshNotification), name: kFIRInstanceIDTokenRefreshNotification, object: nil)

    //Register for remote notifications
    let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
    let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    application.registerUserNotificationSettings(pushNotificationSettings)
    application.registerForRemoteNotifications()

    return true
}

// When app registered for remote notification
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    print("** DEVICE TOKEN = \(deviceToken) **")

    FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Unknown)
    print("** APNS Token set!! **")
}

// When app failed to register for remote notification
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    // Print the error, if failing to register for push notifications
    print("AppDelegate, failed with registering for remote notifications: \(error)")
}

// If no token, or token has changed, this method is called to refresh it!
func tokenRefreshNotification(notification: Notification) {
    if let refreshedToken = FIRInstanceID.instanceID().token() {
        print("InstanceID token: \(refreshedToken)")

    }

    // Connect to FCM since connection may have failed when attempted before having a token.
    connectToFcm()
}

func connectToFcm() {
    FIRMessaging.messaging().connectWithCompletion { (error) in
        if error != nil {
            print("Unable to connect with FCM. \(error)")
        } else {
            print("Connected to FCM.")
        }
    }
}

func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    print("didRegisterUserNotificationSettings")
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject: AnyObject]) {
    // Let FCM know about the message for analytics etc.
    FIRMessaging.messaging().appDidReceiveMessage(userInfo)

    // 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)
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
    // Let FCM know about the message for analytics etc.
    FIRMessaging.messaging().appDidReceiveMessage(userInfo)

    // 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)
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    return PDKClient.sharedInstance().handleCallbackURL(url) || FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

func applicationWillResignActive(application: UIApplication) {
}

func applicationDidEnterBackground(application: UIApplication) {
    print("------APP IN BACKGROUND!!!!!------")
    // Setting the user to offline in Parse - be aware of bad connection, this may fuck it up
    api.setOnlineStatus("offline")

    // Setting the batchnumber to 0 and disconnecting from FCM
    application.applicationIconBadgeNumber = 0;
    FIRMessaging.messaging().disconnect()
    print("Disconnected from FCM.")
}

func applicationWillEnterForeground(application: UIApplication) {
}

func applicationDidBecomeActive(application: UIApplication) {
    print("------APP DID BECOME ACTIVE!!!!!------")
    firebase = FirebaseManager()
    connectToFcm()
    FBSDKAppEvents.activateApp()
}

func applicationWillTerminate(application: UIApplication) {
}

}
我看不出遗漏了什么——有没有人经历过同样的问题,或者知道可能的解决方案?:)


致以最良好的祝愿

高优先级发送通知这是Firebase控制台中的标准配置:-)所以我恐怕这不是一个解决方案:/you sending Message or Data notification?@bobby:从Firebase Notifications控制台,您只能发送通知消息i使用它,它可以工作,但我确实禁用了swizzling。(在plist中添加一个键,阅读文档)优先发送通知在Firebase控制台中是标准的:-)所以我恐怕这不是一个解决方案:/you's sending Message or Data notification?@bobby:从Firebase Notifications控制台,您只能发送通知消息i使用它,它可以工作,但我确实禁用了swizzling。(在plist中添加一个键,读取文档)