Created
March 15, 2017 13:20
-
-
Save flashfabrixx/36b66845eefafaa038cdaefd8f12c05c to your computer and use it in GitHub Desktop.
Zendesk Push Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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