Parse推送通知是否非常不可靠?我收到的只有50%

时间:2015-01-15 14:12:20

标签: ios xcode parse-platform push-notification

我正在构建一个应用程序,它将实现Parse后端以发送推送通知。用户将能够向推送通知中包含的消息发送给其他用户。我一直在玩这个,当我在Parse网站上发送寄存器时很好,但只有大约50%的消息在设备上被接收。还有其他人有这个问题吗?我知道Push Notifications不能保证,但成功率是50%?有任何想法吗?

由于

以下代码:

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


    [Parse setApplicationId:@"***"
    clientKey:@"****"];

    UIUserNotificationType userNotificationTypes =     (UIUserNotificationTypeAlert |
                                                UIUserNotificationTypeBadge |
                                                   UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                         categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];


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.channels = @[ @"global" ];
    [currentInstallation saveInBackground];
}

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

- (void)notifyFriendAtIndex:(NSInteger)index completionHandler:(userCompletionHandler)handler
{

    PFQuery *pushQuery = [PFInstallation query];
    [pushQuery whereKey:@"deviceType" equalTo:@"ios"];

    NSString *pushMessage = [NSString stringWithFormat:@"From %@ HI!", self.currentUser.username];
    NSDictionary *pushData = @{@"alert": pushMessage, @"badge": @0, @"sound": @"notify.wav"};
    PFPush *push = [[PFPush alloc] init];
    [push setQuery:pushQuery];
    [push setData:pushData];
    [push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (error) {
            NSLog(@"Error: %@ %@", error, [error userInfo]);
            handler(NO, error);
        }
        else {
            handler(YES, nil);
        }
    }];

}

2 个答案:

答案 0 :(得分:0)

过去Parse的Push Notification交付我没有遇到任何重大问题。我的一个应用程序有大约32,000个注册设备,似乎接近100%交付。

我还有一些使用Parse作为消息传递和推送后端的聊天应用程序。用户可以订阅特定聊天室并通过分段获得推送通知。其中一个应用刚刚推出,到目前为止,推送通知正在100%完成。我唯一注意到的是有时会有轻微的延迟。也许一两分钟,但我认为这可能是因为wifi连接速度慢。

我还使用PushWoosh进行一般广播推送通知。它们很棒,但有时PushWoosh需要更长时间才能交付。 Parse通常更快,所以底线是我认为Parse的推送通知是可靠的。

答案 1 :(得分:-1)

根据我的经验,我得出的结论是,大多数是由主推送通知提供者(Apple for iOS,Google for Android)。我之所以这样说是因为我们在Parse中有一个应用程序可以在iOS和Android上发送推送通知,有些日子我们不会收到任何推送通知,有些则会收到一些或所有推送通知。这一切都没有改变任何实现。在过去,我使用了另一种称为Urban Airship的推送通知服务(依赖于正确的推送通知传送器),并且存在同样的问题,有些日子几乎"几乎"好吧,其他一些没有工作。

只需检查您的测试设备是否在"安装"具有适当deviceToken集的表。我们通过渠道发送推送通知服务器端。我在这里写的代码也许可以帮到你:

   var dataStruct ={
                        alert: "Hi there!",                            
                        my_additional_info: "normal chat message"
                    };

    Parse.Push.send({
            channels: ["your_custom_registered_installation_channel_device"],
            data: dataStruct
        }).then(function() {
            promise.resolve();
        }, function(error) {
            promise.reject(error);        
    });

通常情况下,它取决于当天,但如果你有这个统计数据(50%),当你的iPhone注册推送通知时,安装并不总是注册/更新

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{        
    PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    // Save/update device tocken
    [currentInstallation setDeviceTokenFromData:deviceToken];
    // store your channel 
    [currentInstallation setChannels:@["channel_123"]];
    [currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        // Do your stuff
    }];
}