- Code: Select all
//============================================================================//
// First player logs in with id "First" and registers their endpoint
[PlayerIO authenticateWithGameId:[NSString stringWithUTF8String:gameID]
connectionId:@"public"
authenticationArguments:@{@"userId":loginID]}
playerInsightSegments:nil
successBlock:^(PIOClient* client)
{
// deviceToken saved from didRegisterForRemoteNotificationsWithDeviceToken
const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
NSString* hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
[client.notifications registerEndpointWithEndpointType:@"ios-push-notifications"
identifier:hexToken
configuration:nil
enabled:YES
successBlock:^(){}
errorBlock:^(PIOError* error){}];
}
errorBlock:^(PIOError* error){}];
//============================================================================//
// Second player wants to send a notification to first player
NSMutableArray* notifications = [NSMutableArray array];
PIONotification* notif = [[[PIONotification alloc] initWithRecipientUserId:@"First"
endpointType:@"ios-push-notifications"] autorelease];
[notifications addObject:notif];
[client.notifications sendNotifications:notifications
successBlock:^(){}
errorBlock:^(PIOError* error){}];
//============================================================================//
The sendNotifications priints out the error: "ERROR: ios-push-notifications: You must specify either 'alert' or 'badgeCount' for iOS push notifications"
How do I set the notification type? Is it done on sending the notification or on registering the endpoint?