I am working on an app that allows "current user" to view an event posted by another user. When the current user join the event I'd like to send a push notification to the user who posted the event. I have set up push notification for my app with Parse. I am able to send push notifications to all users via a channel, but I still cannot figure out how to send a push notification to the specific user. I am able to receive the push notifications on my phone.
I tried to associate the device with a user with the following code:
PFInstallation *installation = [PFInstallation currentInstallation];
installation[@"user"] = [PFUser currentUser];
[installation saveInBackground];
Unfortunately - this makes my app crash. Not sure why there is not error message.
I was thinking of using the following code to send the push notification to a specific user. (This is code i got from Parse Documentation)
// Create our Installation query
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"injuryReports" equalTo:YES];
// Send push notification to query
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery]; // Set our Installation query
[push setMessage:@"Willie Hayes injured by own pop fly."];
[push sendPushInBackground];
- How do you associate the installation with the current user?
- Am I in the right track?
- If you know of a good tutorial, please let me know or if you have implemented something similar and could help me with this problem.
Thank you,