{"_id":"55a911afc8bd450d000dd179","__v":4,"project":"5540ce1b31827a0d007ab1cc","version":{"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","__v":31,"createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"5540d91bbb9e762d00f594ad","project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","__v":14,"pages":["5540d9835cf9682100d61acc","5540d9f25cf9682100d61acf","55a3c52253611017004386bd","55a7744495bf6d25009a0505","55a8f59ac8bd450d000dd11f","55a8f945c8bd450d000dd128","55a8fb52c8bd450d000dd131","55a9046fc8bd450d000dd152","55a9094827a17d210052522a","55a90b6bcf45e1390093f2b8","55a90dd5c8bd450d000dd167","55a911afc8bd450d000dd179","55a9120acf45e1390093f2d0","55ba2eadb3612925009d670a"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T13:14:03.694Z","from_sync":false,"order":3,"slug":"ios","title":"iOS"},"parentDoc":null,"user":"55a5003a750a9a23005332b6","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-17T14:31:11.642Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[**Download Pushwoosh iOS SDK**](https://github.com/Pushwoosh/pushwoosh-ios-sdk)\n\nIn iOS8 Apple introduced [PushKit](https://developer.apple.com/library/prerelease/ios/documentation/NetworkingInternet/Reference/PushKit_Framework/index.html), 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.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"You can only create a VoIP certificate in production mode, not development mode. Therefore, in Pushwoosh iOS app configuration you should always use **Production** gateway for VoIP certificates.\",\n  \"title\": \"IMPORTANT:\"\n}\n[/block]\n**1.** In your **AppDelegate.h** import PushKit framework, add `PKPushRegistryDelegate` protocol and create the `PKPushRegistry` property:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <PushKit/PushKit.h>\\n:::at:::interface AppDelegate : UIResponder <UIApplicationDelegate, PKPushRegistryDelegate>\\n@property (nonatomic, strong) PKPushRegistry* voipRegistry;\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n**2.** In `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {` add:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// handling push on app start\\n[[PushNotificationManager pushManager] handlePushReceived:launchOptions];\\n \\n// make sure we count app open in Pushwoosh stats\\n[[PushNotificationManager pushManager] sendAppOpen];\\n \\n// register for push notifications!\\n[[PushNotificationManager pushManager] registerForPushNotifications];\\n \\n_voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];\\n_voipRegistry.delegate = self;\\n_voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n**3.** Add the following methods to your **AppDelegate class**:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type\\n{\\n    //unsubscribe from push notifications\\n    [[PushNotificationManager pushManager] unregisterForPushNotifications];\\n}\\n \\n- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type\\n{\\n    //push received\\n    [[PushNotificationManager pushManager] handlePushReceived:payload.dictionaryPayload];\\n}\\n \\n- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type\\n{\\n    [[PushNotificationManager pushManager] handlePushRegistration:credentials.token];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n**4.** Enable **Voice over IP** in Background Modes:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/tRSwLfz0Q26qyCRiDk0q_voip.png\",\n        \"voip.png\",\n        \"1372\",\n        \"566\",\n        \"#1e3655\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n**5.** Upload your VoIP certificate to Pushwoosh Control Panel according to [Configuration Guide](http://docs.pushwoosh.com/docs/apns-configuration), and choose the **Production** gateway.\n\nThat’s it! \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"As opposed to the standard push, VoIP pushes do not play notification sounds, or display alerts. However, they wake up your app in the background, which allows you to schedule a local notification.\"\n}\n[/block]","excerpt":"","slug":"voip-pushes","type":"basic","title":"VoIP Pushes"}
[**Download Pushwoosh iOS SDK**](https://github.com/Pushwoosh/pushwoosh-ios-sdk) In iOS8 Apple introduced [PushKit](https://developer.apple.com/library/prerelease/ios/documentation/NetworkingInternet/Reference/PushKit_Framework/index.html), 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. [block:callout] { "type": "warning", "body": "You can only create a VoIP certificate in production mode, not development mode. Therefore, in Pushwoosh iOS app configuration you should always use **Production** gateway for VoIP certificates.", "title": "IMPORTANT:" } [/block] **1.** In your **AppDelegate.h** import PushKit framework, add `PKPushRegistryDelegate` protocol and create the `PKPushRegistry` property: [block:code] { "codes": [ { "code": "#import <PushKit/PushKit.h>\n@interface AppDelegate : UIResponder <UIApplicationDelegate, PKPushRegistryDelegate>\n@property (nonatomic, strong) PKPushRegistry* voipRegistry;", "language": "objectivec" } ] } [/block] **2.** In `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {` add: [block:code] { "codes": [ { "code": "// handling push on app start\n[[PushNotificationManager pushManager] handlePushReceived:launchOptions];\n \n// make sure we count app open in Pushwoosh stats\n[[PushNotificationManager pushManager] sendAppOpen];\n \n// register for push notifications!\n[[PushNotificationManager pushManager] registerForPushNotifications];\n \n_voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];\n_voipRegistry.delegate = self;\n_voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];", "language": "objectivec" } ] } [/block] **3.** Add the following methods to your **AppDelegate class**: [block:code] { "codes": [ { "code": "- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type\n{\n //unsubscribe from push notifications\n [[PushNotificationManager pushManager] unregisterForPushNotifications];\n}\n \n- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type\n{\n //push received\n [[PushNotificationManager pushManager] handlePushReceived:payload.dictionaryPayload];\n}\n \n- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type\n{\n [[PushNotificationManager pushManager] handlePushRegistration:credentials.token];", "language": "objectivec" } ] } [/block] **4.** Enable **Voice over IP** in Background Modes: [block:image] { "images": [ { "image": [ "https://files.readme.io/tRSwLfz0Q26qyCRiDk0q_voip.png", "voip.png", "1372", "566", "#1e3655", "" ] } ] } [/block] **5.** Upload your VoIP certificate to Pushwoosh Control Panel according to [Configuration Guide](http://docs.pushwoosh.com/docs/apns-configuration), and choose the **Production** gateway. That’s it! [block:callout] { "type": "info", "body": "As opposed to the standard push, VoIP pushes do not play notification sounds, or display alerts. However, they wake up your app in the background, which allows you to schedule a local notification." } [/block]