2

I have saved user pointer in instalation class. Web backend shows 0 subscribers Response

I am sending notification using below code

 PFQuery *qry = [PFUser query];
        [qry getObjectWithId:friendObject.objectId]; //friend object is ok like @"Fefl5x7nhl"

        PFQuery *pushQuery = [PFInstallation query];
        [pushQuery whereKey:@"user" matchesQuery:qry];

        // Send push notification to query
        PFPush *push = [[PFPush alloc] init];
        NSString *msgString=[NSString stringWithFormat:@"%@ :%@",
                             [newMessage objectForKey:@"userName"],
                             tfEntry.text];
        [push setQuery:pushQuery]; // Set our Installation query
        NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                              msgString, @"alert",
                              @"ursound.caf", @"sound",
                              @"Increment", @"badge",
                             // @"Optionally a type was set", @"type",
                              nil];
        [push setData:data];
       [push sendPushInBackground];

Installation class My installation class does have this user pointer (friend object) and logically it should be receiver of the notification .

AM i missing something? any suggestion would be great . Thanks for your valuable time

1
  • pls postyour answer again its working Commented Dec 15, 2015 at 13:51

1 Answer 1

2

As long as you have a column on the Installation class called user that is of type Pointer<My_User> and you've actually populated it, your code should work.

There's a section in the Push Notification documentation that talks about adding data to the Installation class:

https://parse.com/docs/push_guide#sending-queries/iOS

Sign up to request clarification or add additional context in comments.

4 Comments

my installation class does have Pointer To user class and i am able to send push notification from mobile. but notifications are not being received (i mean subscriber 0 ) are being shown on parse backend.
I have edited my question and added detail. Now parse server showing that notification is being sent but 0 subscriber .
Your Installation class "user" column is of type Pointer<TBUser> but your query is comparing it to the inbuilt User class, so expecting Pointer<_User>.
Millions of thanks. i have modified my query and now push notifications are being received correctly . PFQuery *qry = [PFQuery queryWithClassName:@"TBUser"]; [qry whereKey:@"objectId" equalTo:friendObject.objectId]; PFQuery *pushQuery = [PFInstallation query]; [pushQuery whereKey:@"user" matchesQuery:qry];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.