-(void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
NSString *dt = [[credentials.token description]stringByTrimmingCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
dt = [dt stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"My token is: %@", dt);
if([credentials.token length] == 0) {
NSLog(@"voip token NULL");
NSString *dt =@"123456";
NSLog(@"Error token is: %@", dt);
[UserDefaults setObject:dt forKey:NS_device_id];
return;
}
NSLog(@"PushCredentials: %@", credentials.token);
[UserDefaults setObject:dt forKey:NS_device_id];
NSString *deviceIdentifier = [[[UIDevicecurrentDevice]identifierForVendor] UUIDString];
QBMSubscription *subscription = [QBMSubscription subscription];
subscription.notificationChannel = QBMNotificationChannelAPNSVOIP;
subscription.deviceUDID = deviceIdentifier;
subscription.deviceToken = [self.voipRegistry pushTokenForType:PKPushTypeVoIP];
[QBRequest createSubscription:subscription successBlock:^(QBResponse *response, NSArray *objects) {
NSLog(@"Create Subscription request - Success");
}
errorBlock:^(QBResponse *response) {
NSLog(@"Create Subscription request - Error");
}];
}
-(void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
NSLog(@"didReceiveIncomingPushWithPayload");
}
-(void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type {
NSString *deviceIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[QBRequest unregisterSubscriptionForUniqueDeviceIdentifier:deviceIdentifier successBlock:^(QBResponse * _Nonnull response) {
NSLog(@"Unregister Subscription request - Success");
}
errorBlock:^(QBError * _Nonnull error) {
NSLog(@"Unregister Subscription request - Error");
}];
}