VoIP pushes
In iOS 8 Apple introduced PushKit, and VoIP pushes - a new type of push notifications. On top of the standard push functionality, a VoIP push allows the app to execute code before displaying the notification to the user.
1. In your AppDelegate.h import PushKit framework, add PKPushRegistryDelegate
protocol and create the PKPushRegistry
property:
import PushKit
@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {
let voipRegistry: PKPushRegistry = PKPushRegistry(queue: DispatchQueue.main)
#import <PushKit/PushKit.h>@interface AppDelegate : UIResponder <UIApplicationDelegate, PKPushRegistryDelegate>@property (nonatomic, strong) PKPushRegistry* voipRegistry;
2. In - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
add:
// handling push on app startPushNotificationManager.push().handlePushReceived(launchOptions)
// make sure we count app open in Pushwoosh statsPushNotificationManager.push().sendAppOpen()
// register for push notifications!PushNotificationManager.push().registerForPushNotifications()
voipRegistry.delegate = selfvoipRegistry.desiredPushTypes = [PKPushType.voIP]
// handling push on app start[[PushNotificationManager pushManager] handlePushReceived:launchOptions];
// make sure we count app open in Pushwoosh stats[[PushNotificationManager pushManager] sendAppOpen];
// register for push notifications![[PushNotificationManager pushManager] registerForPushNotifications];
_voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];_voipRegistry.delegate = self;_voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
3. Add the following methods to your AppDelegate class:
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenForType type: PKPushType) { PushNotificationManager.push().unregisterForPushNotifications()}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) { PushNotificationManager.push().handlePushReceived(payload.dictionaryPayload)}
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, forType: PKPushType) { PushNotificationManager.push().handlePushRegistration(pushCredentials.token)}
- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type{ //unsubscribe from push notifications [[PushNotificationManager pushManager] unregisterForPushNotifications];}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type{ //push received [[PushNotificationManager pushManager] handlePushReceived:payload.dictionaryPayload];}
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type{ [[PushNotificationManager pushManager] handlePushRegistration:credentials.token];
4. Enable Voice over IP in Background Modes:

5. Upload your VoIP certificate to Pushwoosh Control Panel according to Configuration Guide, and choose the Production gateway.
That’s it!
Share your feedback with us
Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.