簡體   English   中英

在解析推送通知中將用戶名作為變量發送

[英]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文件中有pushQuerypushNotify作為屬性。

我收到一條錯誤消息:

方法調用的參數過多,應為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.

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