Parse iOS SDK: Calling Cloud Functions From Xcode

喜欢而已 提交于 2019-12-05 21:29:12
  1. You would call these functions when you want to get the online users. The code for calling these would be:

    [PFCloud callFunctionInBackground:@"registerActivity" withParameters:@{@"user": Put objectId for user here}                             
    block:^(NSString *response, NSError *error) {
                                        if (!error) {
    
                                        }
                                    }];
    
    [PFCloud callFunctionInBackground:@"getOnlineUsers" withParameters:@{} 
    block:^(NSArray *users, NSError *error) { 
    if (!error) 
    {
    
    } }];
    
  2. Yes, I believe it would just be an array of PFUser objects, I would run this just to make sure, though.

  3. Once you get the response from "getOnlineUsers" you should probably send it back up to another cloud code function that uses the master key (Parse.Cloud.useMasterKey();) to access/change user objects, and change the "isOnline" field to YES.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!