Reputation: 183
How can i add the current users username in a parse.com push-notification message?
This is the code i have:
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];
I have pushQuery
and pushNotify
as properties in my .h file.
I get an error message saying:
Too many arguments to method call, expected 1, have 2.
Upvotes: 0
Views: 132
Reputation: 37290
You're attempting to format your message string incorrectly.
[pushNotify setMessage:@"%@ sent you a message", username];
should be:
[pushNotify setMessage:[NSString stringWithFormat:@"%@ sent you a message", username]];
As your code stands now, I believe the error is mistaking "username" for a second argument in setMessage
, thus the error message: "Too many arguments to method call, expected 1, have 2."
Upvotes: 1