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

Muhammad Adnan
  • 2,668
  • 15
  • 27

1 Answers1

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

Timothy Walters
  • 16,866
  • 2
  • 41
  • 49
  • 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. – Muhammad Adnan Aug 07 '14 at 09:49
  • I have edited my question and added detail. Now parse server showing that notification is being sent but 0 subscriber . – Muhammad Adnan Aug 07 '14 at 10:05
  • Your `Installation` class "user" column is of type `Pointer` but your query is comparing it to the inbuilt User class, so expecting `Pointer<_User>`. – Timothy Walters Aug 07 '14 at 11:42
  • 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]; – Muhammad Adnan Aug 07 '14 at 12:23