2015-09-01 40 views
0

我想在我的iOS应用程序中使用解析通知,我按照parse.com网站上的步骤指导了一步步,但它仍然无效,这里是我的应用程序委托.M解析通知不适用于iOS

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 



    [Parse enableLocalDatastore]; 

    // Initialize Parse. 
    [Parse setApplicationId:@"XXXXXXXXXXXX" 
        clientKey:@"XXXXXXXXXXX"]; 




    // [Optional] Track statistics around application opens. 
    [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions]; 


    NSLog(@"START"); 
    // Register for Push Notitications 
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | 
                UIUserNotificationTypeBadge | 
                UIUserNotificationTypeSound); 

    if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
    { 
     // iOS 8 Notifications 
     [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 

     [application registerForRemoteNotifications]; 
    } 
    else 
    { 
     // iOS < 8 Notifications 
     [application registerForRemoteNotificationTypes: 
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; 
    } 

     [self grabStoryboard]; 
    [FBLoginView class]; 
    [FBProfilePictureView class]; 


    return YES; 
} 


- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
    // Store the deviceToken in the current installation and save it to Parse. 
    PFInstallation *currentInstallation = [PFInstallation currentInstallation]; 
    [currentInstallation setDeviceTokenFromData:deviceToken]; 
    [currentInstallation saveInBackground]; 
} 

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { 
    if (error.code == 3010) { 
     NSLog(@"Push notifications are not supported in the iOS Simulator."); 
    } else { 
     // show some alert or otherwise handle the failure to register. 
     NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error); 
    } 
} 

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 
    [PFPush handlePush:userInfo]; 
} 

在parse.com我看到,我已经1个注册的设备,但是当我点击“发送推送”发出的推是0

回答

0

您应该检查你解析应用程序设置。转到推送通知并查看您是否上传了正确的证书(Apple Push Certificates)。这应该可以解决你的问题。

+0

是的,我用同样的包标识符上传它我的应用 –

+0

但仍然无法正常工作 –

0

将此添加到远程通知部分的注册表中。

[currentInstallation setObject:[PFUser currentUser].objectId forKey:@"owner"]; 

,并在那里你把你推添加此

PFQuery *pushQuery = [PFInstallation query]; 
[pushQuery whereKey:@"owner" containedIn:self.recipients]; 

此外,如果这不起作用告诉我你的方法,你把你推