{"__v":1,"_id":"57ec28abd9dc160e001575f8","category":{"__v":14,"_id":"5540d91bbb9e762d00f594ad","pages":["5540d9835cf9682100d61acc","5540d9f25cf9682100d61acf","55a3c52253611017004386bd","55a7744495bf6d25009a0505","55a8f59ac8bd450d000dd11f","55a8f945c8bd450d000dd128","55a8fb52c8bd450d000dd131","55a9046fc8bd450d000dd152","55a9094827a17d210052522a","55a90b6bcf45e1390093f2b8","55a90dd5c8bd450d000dd167","55a911afc8bd450d000dd179","55a9120acf45e1390093f2d0","55ba2eadb3612925009d670a"],"project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T13:14:03.694Z","from_sync":false,"order":3,"slug":"ios","title":"iOS"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"5540e0f5bb9e762d00f594c0","version":{"__v":31,"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-28T20:31:39.535Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"With the new iOS 10 you can attach a static or animated (gif) image, or even a video to push notifications. It will be displayed right in the notification when the user force-taps it.\n\nHere's an example:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/64065bc-PW_rich_push.gif\",\n        \"PW_rich_push.gif\",\n        619,\n        535,\n        \"#000000\"\n      ],\n      \"caption\": \"iOS 10 rich notifications is action!\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"You can see it in action right now!\",\n  \"body\": \"Install [Pushwoosh Demo App](https://itunes.apple.com/us/app/push-on/id1122054952?mt=8) from the App Store. Scan the QR code of Pushwoosh Demo App in your Pushwoosh Account and go to the Step 4.\"\n}\n[/block]\nEnabling this functionality is very simple, with very little coding involved. Let's do it!\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Creating Notification Service Extension\"\n}\n[/block]\nFirst create a [Notification Service Extension](https://developer.apple.com/reference/usernotifications/unnotificationserviceextension). This extension downloads the content that will be shown to the user.\n\nAdd new target to your project (`File->New->Target`) and create *Notification Service Extension*.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b6f3354-Screenshot_9_28_16__3_37_PM.png\",\n        \"Screenshot_9_28_16__3_37_PM.png\",\n        1452,\n        1022,\n        \"#ebecec\"\n      ],\n      \"caption\": \"Creating Notification Service Extension\"\n    }\n  ]\n}\n[/block]\nMake sure you embed your new extension in your app!\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a17ee7d-Screenshot_9_28_16__3_39_PM.png\",\n        \"Screenshot_9_28_16__3_39_PM.png\",\n        1454,\n        1038,\n        \"#eaeae9\"\n      ],\n      \"caption\": \"Select your app to embed the extension\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Note that notification extension has its own Bundle Id (*ex:* `com.pushwoosh.pushon.NotificationService`) as well as its own **Apple App ID** and **Provisioning profile** which must be setup in Apple Developer Portal separately.\",\n  \"title\": \"Notification Service Extension has a separate Apple App ID and Provisioning profile!\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Architectures\",\n  \"body\": \"Make sure Notification Service Extension supports **Standard architectures (armv7, arm64)** (**${ExtensionTarget} -> Build Settings -> Architectures**).\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Notification Service Extension Code\"\n}\n[/block]\nThe code is available in our [Sample app](https://github.com/Pushwoosh/pushwoosh-ios-sdk/tree/master/Samples/iPhone) at GitHub:\n[https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/Samples/iPhone/NotificationService/NotificationService.m](https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/Samples/iPhone/NotificationService/NotificationService.m) \n\nJust Copy & Paste it to your extension.  The code downloads the attachment and calls the notification content handler.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Allowing non-secure attachment URL's\"\n}\n[/block]\nNotification Service Extension is a separate binary and **has its own Info.plist** file.\nStarting with iOS9 release to download the content from non-https URL (ex: *http://*) you have to add **App Transport Security Settings** with **Allow Arbitrary Loads** flag set to YES to **extension's Info.plist** file.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4569dcf-Info_plist.png\",\n        \"Info_plist.png\",\n        1082,\n        598,\n        \"#dddddb\"\n      ],\n      \"caption\": \"Info.plist\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. Sending Rich Notification\"\n}\n[/block]\nIn order to send a rich notification just specify the file's URL in the \"iOS10+ Media attachment\" field \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3d1d055-slack-imgs_com.jpg\",\n        \"slack-imgs_com.jpg\",\n        740,\n        535,\n        \"#e2e9e9\"\n      ]\n    }\n  ]\n}\n[/block]\nWoosh! Force-tap the notification and you are all done!\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3a9249a-PW_rich_push_device.gif\",\n        \"PW_rich_push_device.gif\",\n        235,\n        456,\n        \"#000000\"\n      ],\n      \"caption\": \"Amazing, isn't it!\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"ios-10-rich-notifications-integration","type":"basic","title":"iOS 10 Rich Notifications Integration"}

iOS 10 Rich Notifications Integration


With the new iOS 10 you can attach a static or animated (gif) image, or even a video to push notifications. It will be displayed right in the notification when the user force-taps it. Here's an example: [block:image] { "images": [ { "image": [ "https://files.readme.io/64065bc-PW_rich_push.gif", "PW_rich_push.gif", 619, 535, "#000000" ], "caption": "iOS 10 rich notifications is action!" } ] } [/block] [block:callout] { "type": "success", "title": "You can see it in action right now!", "body": "Install [Pushwoosh Demo App](https://itunes.apple.com/us/app/push-on/id1122054952?mt=8) from the App Store. Scan the QR code of Pushwoosh Demo App in your Pushwoosh Account and go to the Step 4." } [/block] Enabling this functionality is very simple, with very little coding involved. Let's do it! [block:api-header] { "type": "basic", "title": "1. Creating Notification Service Extension" } [/block] First create a [Notification Service Extension](https://developer.apple.com/reference/usernotifications/unnotificationserviceextension). This extension downloads the content that will be shown to the user. Add new target to your project (`File->New->Target`) and create *Notification Service Extension*. [block:image] { "images": [ { "image": [ "https://files.readme.io/b6f3354-Screenshot_9_28_16__3_37_PM.png", "Screenshot_9_28_16__3_37_PM.png", 1452, 1022, "#ebecec" ], "caption": "Creating Notification Service Extension" } ] } [/block] Make sure you embed your new extension in your app! [block:image] { "images": [ { "image": [ "https://files.readme.io/a17ee7d-Screenshot_9_28_16__3_39_PM.png", "Screenshot_9_28_16__3_39_PM.png", 1454, 1038, "#eaeae9" ], "caption": "Select your app to embed the extension" } ] } [/block] [block:callout] { "type": "warning", "body": "Note that notification extension has its own Bundle Id (*ex:* `com.pushwoosh.pushon.NotificationService`) as well as its own **Apple App ID** and **Provisioning profile** which must be setup in Apple Developer Portal separately.", "title": "Notification Service Extension has a separate Apple App ID and Provisioning profile!" } [/block] [block:callout] { "type": "warning", "title": "Architectures", "body": "Make sure Notification Service Extension supports **Standard architectures (armv7, arm64)** (**${ExtensionTarget} -> Build Settings -> Architectures**)." } [/block] [block:api-header] { "type": "basic", "title": "2. Notification Service Extension Code" } [/block] The code is available in our [Sample app](https://github.com/Pushwoosh/pushwoosh-ios-sdk/tree/master/Samples/iPhone) at GitHub: [https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/Samples/iPhone/NotificationService/NotificationService.m](https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/Samples/iPhone/NotificationService/NotificationService.m) Just Copy & Paste it to your extension. The code downloads the attachment and calls the notification content handler. [block:api-header] { "type": "basic", "title": "3. Allowing non-secure attachment URL's" } [/block] Notification Service Extension is a separate binary and **has its own Info.plist** file. Starting with iOS9 release to download the content from non-https URL (ex: *http://*) you have to add **App Transport Security Settings** with **Allow Arbitrary Loads** flag set to YES to **extension's Info.plist** file. [block:image] { "images": [ { "image": [ "https://files.readme.io/4569dcf-Info_plist.png", "Info_plist.png", 1082, 598, "#dddddb" ], "caption": "Info.plist" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. Sending Rich Notification" } [/block] In order to send a rich notification just specify the file's URL in the "iOS10+ Media attachment" field [block:image] { "images": [ { "image": [ "https://files.readme.io/3d1d055-slack-imgs_com.jpg", "slack-imgs_com.jpg", 740, 535, "#e2e9e9" ] } ] } [/block] Woosh! Force-tap the notification and you are all done! [block:image] { "images": [ { "image": [ "https://files.readme.io/3a9249a-PW_rich_push_device.gif", "PW_rich_push_device.gif", 235, 456, "#000000" ], "caption": "Amazing, isn't it!" } ] } [/block]