[英]Sending username as a variable in a parse push-notification
如何在parse.com推送通知消息中添加當前用戶的用戶名?
這是我的代碼:
pushQuery = [PFInstallation query];
[pushQuery whereKey:@"userStable" equalTo:SecondStable];
pushNotify = [[PFPush alloc] init];
[pushNotify setQuery:pushQuery];
NSString *username = currentUser[@"username"];
[pushNotify setMessage:@"%@ sent you a message", username];
[pushNotify sendPushInBackground];
我的.h文件中有pushQuery
和pushNotify
作為屬性。
我收到一條錯誤消息:
方法調用的參數過多,應為1,為2。
您試圖錯誤地設置消息字符串的格式。
[pushNotify setMessage:@"%@ sent you a message", username];
應該:
[pushNotify setMessage:[NSString stringWithFormat:@"%@ sent you a message", username]];
就您的代碼而言,我認為錯誤是將“ username”誤稱為setMessage
的第二個參數,因此錯誤消息:“方法調用的參數過多,預期為1,有2個。”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.