Skip to content

Instantly share code, notes, and snippets.

@flashfabrixx
Created March 15, 2017 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flashfabrixx/36b66845eefafaa038cdaefd8f12c05c to your computer and use it in GitHub Desktop.
Save flashfabrixx/36b66845eefafaa038cdaefd8f12c05c to your computer and use it in GitHub Desktop.
Zendesk Push Configuration
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// ...
// Convert device token from NSData to NSString
NSMutableString* pushTokenString = [NSMutableString stringWithString:[self.description uppercaseString]];
[pushTokenString replaceOccurrencesOfString:@"<" withString:@"" options:0 range:NSMakeRange(0, pushTokenString.length)];
[pushTokenString replaceOccurrencesOfString:@">" withString:@"" options:0 range:NSMakeRange(0, pushTokenString.length)];
[pushTokenString replaceOccurrencesOfString:@" " withString:@"" options:0 range:NSMakeRange(0, pushTokenString.length)];
[self enablePushNotificationForZendesk:pushTokenString];
// ...
}
- (void)enablePushNotificationForZendesk:(NSString *)deviceToken {
if (!deviceToken || deviceToken.length == 0) {
NSLog(@"Error enabling Zendesk push notifications: Device token not set.");
return;
}
[[ZDKConfig instance] enablePushWithDeviceID:deviceToken callback:^(ZDKPushRegistrationResponse *registrationResponse, NSError *error){
if (error) {
NSLog(@"Error enabling Zendesk push notification: %@", [error userInfo]);
} else if (registrationResponse) {
NSLog(@"Success enabling Zendesk push notification: %@", registrationResponse);
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment