解析推送通知内部测试仪的设备不会注册ios

时间:2015-09-09 10:14:06

标签: ios parse-platform push-notification apple-push-notifications

我即将发布我的第一个移动应用程序。我使用解析来推送通知。我为推送通知创建了所有证书。现在在developer.apple.com中,我的应用程序的权限看起来像这样。

http://i.imgur.com/eH6zs3M.png?1

我没有创建开发人员证书,因为我已经测试过了。

我将此应用程序发送到AppStore,我将使用内部测试人员对其进行测试。但是当他们打开应用程序并对通知说“是”时,测试人员的设备无法添加到Parse的数据库中。这个应用程序有什么问题?

编辑:我用Swift 2编写代码

didRegisterForRemoteNotificationsWithDeviceToken是:

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    let installation = PFInstallation.currentInstallation()
    installation.setDeviceTokenFromData(deviceToken)
    installation.saveInBackground()

    PFPush.subscribeToChannelInBackground("") { (succeeded, error) in
        if succeeded {
            print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.");
        } else {
            print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.", error)
        }
    }
}

1 个答案:

答案 0 :(得分:0)

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        ParseCrashReporting.enable()

        Parse.setApplicationId(“xxxxx”, clientKey: “xxxxxx”)


        PFUser.enableAutomaticUser()
        let defaultACL = PFACL();

        // If you would like all objects to be private by default, remove this line.
        defaultACL.setPublicReadAccess(true)

        let cu = PFUser.currentUser()
        println("current user - \(cu?.email)")
        PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser:true)

        if application.applicationState != UIApplicationState.Background {
            // Track an app open here if we launch with a push, unless
            // "content_available" was used to trigger a background push (introduced in iOS 7).
            // In that case, we skip tracking here to avoid double counting the app-open.

            let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
            let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
            var noPushPayload = false;
            if let options = launchOptions {
                noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil;
            }
            if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
                PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
            }
        }
        if application.respondsToSelector("registerUserNotificationSettings:") {
            let userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
            let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
            application.registerUserNotificationSettings(settings)
            application.registerForRemoteNotifications()
        } else {
            let types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound
            application.registerForRemoteNotificationTypes(types)
        }
}