Xcode,Parse.com - 推送通知不会显示在我的手机上。

时间:2014-10-06 23:21:46

标签: xcode swift push-notification parse-platform

遵循Parse.com上的指南,了解如何创建证书并准备配置帐户以接受推送通知。当我转到首选项/帐户时:它显示在底部,但是当我尝试从构建设置选项卡中选择它时,它没有显示,我总是收到此错误:"no valid 'aps-environment' entitlement string found for application"

我的手机被Parse应用程序识别,并且它成功发送通知,但我的手机从未接收过它们。我尝试了几次,使用了几个Xcode& amp;解析应用程序。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        Parse.setApplicationId("MyAppId", clientKey: "MyAppClientKey")

        var notificationType: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound

        var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
        UIApplication.sharedApplication().registerUserNotificationSettings(settings)
        UIApplication.sharedApplication().registerForRemoteNotifications()

        return true
    }

    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

        var currentInstallation: PFInstallation = PFInstallation()
        currentInstallation.setDeviceTokenFromData(deviceToken)
        currentInstallation.saveInBackground()
    }

    func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {

        println(error.localizedDescription)
    }

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

        PFPush.handlePush(userInfo)
    }

1 个答案:

答案 0 :(得分:0)

1)您是否允许来自应用项目的推送通知?

2)您是否在解析和应用中设置了正确的构建标识符?

我有另一种委托方法,我在你的帖子中看不到。

    func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings!) 
    {
        UIApplication.sharedApplication().registerForRemoteNotifications()

    }