{"_id":"5728dc7896cb101900eb0449","user":"56cecbb2e50c9c1b008303eb","project":"56cecbdb44c5700b0095c03a","__v":16,"category":{"_id":"56d3693d1660770b0008115a","pages":["56e51ce64ddf0b0e004afbbc","56e51d092d90970e00af1b1a","56e69b0c00ea361700d4fa78","56ea7bdfcf35bf0e00adb91d"],"version":"56cecbdc44c5700b0095c03d","__v":4,"project":"56cecbdb44c5700b0095c03a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-28T21:40:13.300Z","from_sync":false,"order":2,"slug":"ios","title":"iOS"},"githubsync":"","version":{"_id":"56cecbdc44c5700b0095c03d","project":"56cecbdb44c5700b0095c03a","__v":10,"createdAt":"2016-02-25T09:39:40.121Z","releaseDate":"2016-02-25T09:39:40.121Z","categories":["56cecbdc44c5700b0095c03e","56d1d2c05ad7ad0b00b7e809","56d1d2fa5ad7ad0b00b7e80a","56d369331660770b00081159","56d3693d1660770b0008115a","56e5361e7990160e002e3fbc","56e5362775eb791700a9c4d2","57a9030947f2f419009188d4","57b4705ee9e4c60e00f6f4c3","5828f5b04774ab0f005179a2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-03T17:14:32.195Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Integrate the PushApps iOS SDK\"\n}\n[/block]\nBefore creating your PushApps content recommendations Today Widget, you'll need to integrate PushApps SDK. [Please follow the instructions here](doc:sdk-installation-manual).\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"App Transport Security\",\n  \"body\": \"Please make sure to enable all network requests for *.pushapps.mobi, in order to enable the PushApps SDK and content recommendations.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Adding a Today Widget to your app\"\n}\n[/block]\n2.1 Go to File > New > Target...\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/zfs0Fue5Q6yJdQhu1zw6_Screen%20Shot%202016-05-04%20at%2010.51.13%20AM.png\",\n        \"Screen Shot 2016-05-04 at 10.51.13 AM.png\",\n        \"497\",\n        \"496\",\n        \"#1ea1a2\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2.2 Under iOS > choose Application Extensions > select the Today Extension > press Next\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/yN4UFipLQl2sdo88N0MF_Screen%20Shot%202016-05-04%20at%2010.53.59%20AM.png\",\n        \"Screen Shot 2016-05-04 at 10.53.59 AM.png\",\n        \"732\",\n        \"520\",\n        \"#224981\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2.3 Choose a name for your widget and make sure that the rest of the details are correct. Once finished, press the Finish button\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ljZS5r3GR12g0KPhs8TS_Screen%20Shot%202016-05-04%20at%2010.57.13%20AM.png\",\n        \"Screen Shot 2016-05-04 at 10.57.13 AM.png\",\n        \"730\",\n        \"517\",\n        \"#245995\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2.4 You'll see the Activate Scheme popup > choose to Activate\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/i2c7HkEhScuB0rdIFm6q_Screen%20Shot%202016-05-04%20at%2011.01.54%20AM.png\",\n        \"Screen Shot 2016-05-04 at 11.01.54 AM.png\",\n        \"513\",\n        \"297\",\n        \"#29a5c9\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2.5 To verify that the process was completed with success, please verify that those new folder and files were created in your project:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/xlWcLMOZSvexfbF9oNmy_Screen%20Shot%202016-05-04%20at%2011.04.52%20AM.png\",\n        \"Screen Shot 2016-05-04 at 11.04.52 AM.png\",\n        \"231\",\n        \"223\",\n        \"#8a4c41\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Showing content recommendations in the Today Widget\"\n}\n[/block]\n3.1 Add the PushApps.framework to the Today Widget target. Go to target page, under General tab and press the + sign under Linked Frameworks. If you can't find the PushApps framework in the list, click on Add Other and choose the PushApps.framework file:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/zQb8uh1yT1q6rapMuO1u_Screen%20Shot%202016-05-04%20at%2012.22.41%20PM.png\",\n        \"Screen Shot 2016-05-04 at 12.22.41 PM.png\",\n        \"713\",\n        \"231\",\n        \"#232f57\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nAnd after adding the PushApps SDK:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5vNbKKkHQ0ixRd19UgKJ_Screen%20Shot%202016-05-04%20at%2012.24.04%20PM.png\",\n        \"Screen Shot 2016-05-04 at 12.24.04 PM.png\",\n        \"725\",\n        \"160\",\n        \"#8a4327\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"AdSupport Library\",\n  \"body\": \"Please consider adding also AdSupport.framework to the Linked Frameworks list, if you use it in your app as well. It will help PushApps personalised better the content recommendations for each app user.\"\n}\n[/block]\n3.2 Download the [PushApps widget files](https://s3.amazonaws.com/pushapps-sdk/ios/today_widget/pushapps-today-widget.zip).\n\n3.3 Replace those files with the ones currently in your project.\n\n3.4 Inside TodayViewController.m, replace our demo SDK key with yours.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Hes6YRiRSmSZE5Hf6AFU_Screen%20Shot%202016-05-04%20at%2012.36.08%20PM.png\",\n        \"Screen Shot 2016-05-04 at 12.36.08 PM.png\",\n        \"590\",\n        \"169\",\n        \"#ce4043\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n3.5 Inside TodayViewController.m, search for \"campaign_id\" and replace the value with your campaign.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/EVRC6CYRrCQI3Rv4fjKg_Screen%20Shot%202016-05-04%20at%2012.36.53%20PM.png\",\n        \"Screen Shot 2016-05-04 at 12.36.53 PM.png\",\n        \"840\",\n        \"225\",\n        \"#c2344c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n3.6 That's it. Run it on your device or simulator. Drag the top curtain and add the widget to see your content recommendations.\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Demo App Source Code\",\n  \"body\": \"You can find our demo app with the full source code on [our Github page](https://github.com/PushAppsPlatform/iOSDemo). Please fill free to contact us with any question.\"\n}\n[/block]","excerpt":"","slug":"ios-today-widget-with-pushapps-content-recommendations","type":"basic","title":"Today Widget With PushApps Content Recommendations"}

Today Widget With PushApps Content Recommendations


[block:api-header] { "type": "basic", "title": "1. Integrate the PushApps iOS SDK" } [/block] Before creating your PushApps content recommendations Today Widget, you'll need to integrate PushApps SDK. [Please follow the instructions here](doc:sdk-installation-manual). [block:callout] { "type": "warning", "title": "App Transport Security", "body": "Please make sure to enable all network requests for *.pushapps.mobi, in order to enable the PushApps SDK and content recommendations." } [/block] [block:api-header] { "type": "basic", "title": "2. Adding a Today Widget to your app" } [/block] 2.1 Go to File > New > Target... [block:image] { "images": [ { "image": [ "https://files.readme.io/zfs0Fue5Q6yJdQhu1zw6_Screen%20Shot%202016-05-04%20at%2010.51.13%20AM.png", "Screen Shot 2016-05-04 at 10.51.13 AM.png", "497", "496", "#1ea1a2", "" ] } ] } [/block] 2.2 Under iOS > choose Application Extensions > select the Today Extension > press Next [block:image] { "images": [ { "image": [ "https://files.readme.io/yN4UFipLQl2sdo88N0MF_Screen%20Shot%202016-05-04%20at%2010.53.59%20AM.png", "Screen Shot 2016-05-04 at 10.53.59 AM.png", "732", "520", "#224981", "" ] } ] } [/block] 2.3 Choose a name for your widget and make sure that the rest of the details are correct. Once finished, press the Finish button [block:image] { "images": [ { "image": [ "https://files.readme.io/ljZS5r3GR12g0KPhs8TS_Screen%20Shot%202016-05-04%20at%2010.57.13%20AM.png", "Screen Shot 2016-05-04 at 10.57.13 AM.png", "730", "517", "#245995", "" ] } ] } [/block] 2.4 You'll see the Activate Scheme popup > choose to Activate [block:image] { "images": [ { "image": [ "https://files.readme.io/i2c7HkEhScuB0rdIFm6q_Screen%20Shot%202016-05-04%20at%2011.01.54%20AM.png", "Screen Shot 2016-05-04 at 11.01.54 AM.png", "513", "297", "#29a5c9", "" ] } ] } [/block] 2.5 To verify that the process was completed with success, please verify that those new folder and files were created in your project: [block:image] { "images": [ { "image": [ "https://files.readme.io/xlWcLMOZSvexfbF9oNmy_Screen%20Shot%202016-05-04%20at%2011.04.52%20AM.png", "Screen Shot 2016-05-04 at 11.04.52 AM.png", "231", "223", "#8a4c41", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Showing content recommendations in the Today Widget" } [/block] 3.1 Add the PushApps.framework to the Today Widget target. Go to target page, under General tab and press the + sign under Linked Frameworks. If you can't find the PushApps framework in the list, click on Add Other and choose the PushApps.framework file: [block:image] { "images": [ { "image": [ "https://files.readme.io/zQb8uh1yT1q6rapMuO1u_Screen%20Shot%202016-05-04%20at%2012.22.41%20PM.png", "Screen Shot 2016-05-04 at 12.22.41 PM.png", "713", "231", "#232f57", "" ] } ] } [/block] And after adding the PushApps SDK: [block:image] { "images": [ { "image": [ "https://files.readme.io/5vNbKKkHQ0ixRd19UgKJ_Screen%20Shot%202016-05-04%20at%2012.24.04%20PM.png", "Screen Shot 2016-05-04 at 12.24.04 PM.png", "725", "160", "#8a4327", "" ] } ] } [/block] [block:callout] { "type": "warning", "title": "AdSupport Library", "body": "Please consider adding also AdSupport.framework to the Linked Frameworks list, if you use it in your app as well. It will help PushApps personalised better the content recommendations for each app user." } [/block] 3.2 Download the [PushApps widget files](https://s3.amazonaws.com/pushapps-sdk/ios/today_widget/pushapps-today-widget.zip). 3.3 Replace those files with the ones currently in your project. 3.4 Inside TodayViewController.m, replace our demo SDK key with yours. [block:image] { "images": [ { "image": [ "https://files.readme.io/Hes6YRiRSmSZE5Hf6AFU_Screen%20Shot%202016-05-04%20at%2012.36.08%20PM.png", "Screen Shot 2016-05-04 at 12.36.08 PM.png", "590", "169", "#ce4043", "" ] } ] } [/block] 3.5 Inside TodayViewController.m, search for "campaign_id" and replace the value with your campaign. [block:image] { "images": [ { "image": [ "https://files.readme.io/EVRC6CYRrCQI3Rv4fjKg_Screen%20Shot%202016-05-04%20at%2012.36.53%20PM.png", "Screen Shot 2016-05-04 at 12.36.53 PM.png", "840", "225", "#c2344c", "" ] } ] } [/block] 3.6 That's it. Run it on your device or simulator. Drag the top curtain and add the widget to see your content recommendations. [block:callout] { "type": "success", "title": "Demo App Source Code", "body": "You can find our demo app with the full source code on [our Github page](https://github.com/PushAppsPlatform/iOSDemo). Please fill free to contact us with any question." } [/block]