簡體   English   中英

如何使用解析向特定組成員發送推送通知?

[英]How to send push notification to particular group members using parse?

我正在開發一個使用parse作為后端的社交消息應用程序。 當有人在群組中發短信時,我需要向群組成員發送推送通知。

我的代碼是:

PFQuery* getMembers = [PFQuery queryWithClassName:@"Group"];
[getMembers whereKey:@"objectId" equalTo:groupId];
[getMembers includeKey:PF_RECENT_USER];
[getMembers findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        NSArray *ar = [[NSArray alloc]init];
        ar=[[objects objectAtIndex:0]objectForKey:@"members"];
        NSLog(@"members %@",ar);
        PFQuery *queryInstallation = [PFInstallation query];
        [queryInstallation whereKey:PF_INSTALLATION_USER matchesKey:PF_RECENT_USER inQuery:getMembers];

        PFPush *push = [[PFPush alloc] init];
        [push setQuery:queryInstallation];
        //[push setMessage:text];
        NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                              text, @"alert",
                              @"ursound.caf", @"sound",
                              @"Increment", @"badge",
                              // @"Optionally a type was set", @"type",
                              nil];
        [push setData:data];
        [push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
         {
             if (error != nil)
             {
                 NSLog(@"SendPushNotification send error.");
             }
         }];
       }
}];

請指導我糾正錯誤。

您可以通過創建頻道將推送通知發送給gruop成員,然后將用戶訂閱到該頻道。 然后,您可以將推送通知發送到特定頻道。

訪問https://parse.com/docs/ios/guide#push-notifications ,以獲取有關創建頻道和使用頻道發送通知的更多幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM