【问题标题】:iOS App Notification with Parse.com带有 Parse.com 的 iOS 应用通知
【发布时间】:2015-05-29 04:31:38
【问题描述】:

我有两个 iOS 应用程序与一个 Parse 应用程序帐户相关联。现在我们想为两个应用程序使用相同的Parse 帐户实现推送通知。

这可能吗?

【问题讨论】:

    标签: ios parse-platform push-notification


    【解决方案1】:

    Guide

    与一个 parse.com 连接

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

    获取设备目录

    PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    [currentInstallation setDeviceTokenFromData:deviceToken];
            currentInstallation.channels = @[ @"globle" ];
    [currentInstallation saveInBackground];
    NSString * udid=[[[[deviceToken description]
                               stringByReplacingOccurrencesOfString: @"<" withString: @""]
                              stringByReplacingOccurrencesOfString: @">" withString: @""]
                             stringByReplacingOccurrencesOfString: @" " withString: @""];
    

    发送推送通知

        NSMutableArray * arrUserParseQuery=[[NSMutableArray alloc]init];
    //add user to send pushNotification
         for (NSString * strObjectId in arrUsers) {
            PFQuery * objUserQuery=[PFQuery queryWithClassName:@"_User"];
            [objUserQuery whereKey:@"objectId" equalTo:strObjectId];
            [arrUserParseQuery addObject:objUserQuery];
         }
         [pushQuery whereKey:@"UserId" matchesQuery:[PFQuery orQueryWithSubqueries:arrUserParseQuery]];
         PFPush *push = [[PFPush alloc] init];
         [push setQuery:pushQuery]; // Set our Installation query
         [push setMessage:@"Notification text"];
         [push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
                NSLog(@"Errer of push notification %@",error);
         }];
    

    您必须在 parse.com 中设置 Certificates 才能发送 pushNotification。

    【讨论】:

    • 请仔细阅读我的问题,我的问题是我可以将两个 ios 应用程序与一个 parse.com 应用程序连接以进行推送通知
    • 您在发送 PushNotification 中阅读了我的回答,您可以向可能的用户发送通知。
    【解决方案2】:

    是的,有可能。请参阅下面的屏幕截图,您可以在其中为多个 iOS 应用上传多个 p12 证书文件。然后您将根据应用发送推送,例如使用渠道。一个应用程序的一个频道名称,第二个应用程序的另一个频道。您还可以在安装类中添加额外的字段,以便您可以通过查询用户向用户发送提前推送通知。

    还有一个helpful link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多