简体   繁体   English

解析通知在iOS上不起作用

[英]Parse notifications doesn't work on iOS

i'm trying to use parse notification in my iOS app, i followed step by step the guide on the parse.com website but it still doesn't works, here is my app delegate.m 我正在尝试在我的iOS应用中使用解析通知,我在parse.com网站上逐步遵循了指南,但仍然无法正常工作,这是我的应用委托。

- (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];
}

On parse.com i see that i've 1 registered device, but when i click on "send push" the pushes sent are 0 在parse.com上,我看到我已经注册了1个设备,但是当我单击“发送推送”时,发送的推送为0

You should check you App settings on Parse. 您应该在“解析”中检查“应用”设置。 Go to push notifications and see if you've uploaded the right certificates (Apple Push Certificates). 转到推送通知,查看您是否已上传正确的证书(Apple Push Certificates)。 This should solve your problem. 这应该可以解决您的问题。

add this in the did register for remote notifications section. 将其添加到“为远程通知注册”部分。

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

and where you send your push add this 在您发送推送的位置添加

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

also if this does not work show me your method where you send your push 另外,如果这不起作用,请向我显示您的方法,将推送发送到哪里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM