Question

I have configured my Parse reception api like so:

[Parse setApplicationId:@"***" clientKey:@"***"];

[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
 UIRemoteNotificationTypeAlert|
 UIRemoteNotificationTypeSound];

and

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    // Store the deviceToken in the current installation and save it to Parse.
     PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    [currentInstallation setDeviceTokenFromData:deviceToken];
    [currentInstallation saveInBackground];
}

Then in my code, I add channels to subscribe to like so:

PFInstallation *currentInstallation = [PFInstallation currentInstallation];
NSMutableArray *array = [NSMutableArray array];

for (Room *aRoom in rooms) {

    NSString *strChannel = [NSString stringWithFormat:@"pr_%@", aRoom.roomId];
    [array addObject:strChannel];
}

[currentInstallation setChannels:array];

In my example, the channel is "pr_4".

When I push something on this channel though, the parse dashboard tells me that nobody has subscribed to the channel "pr_4". I don't understand what I am doing wrong.

Was it helpful?

Solution

In the code you provided, you never actually save the PFInstallation object to parse.com. You should add :

[currentInstallation saveInBackground];

at the end of your code, right after you set the channels.


Side-note: you can also use the method subscribeToChannelInBackground: from the PFPush class in order to subscribe a device to a channel:

subscribeToChannelInBackground:

Asynchronously subscribes the device to a channel of push notifications.

+ (void)subscribeToChannelInBackground:(NSString *)channel

Parameters

channel

The channel to subscribe to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top