{"_id":"5828f9296a1d1f0f00b9445b","githubsync":"","parentDoc":null,"project":"56cecbdb44c5700b0095c03a","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"},"category":{"_id":"5828f5b04774ab0f005179a2","project":"56cecbdb44c5700b0095c03a","version":"56cecbdc44c5700b0095c03d","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-11-13T23:22:24.866Z","from_sync":false,"order":3,"slug":"phonegap-cordova","title":"Phonegap / Cordova"},"user":"56cecbb2e50c9c1b008303eb","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-11-13T23:37:13.823Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"1. Open the command line inside your app directory, and add the PushApps plugin:\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Do Not Forget!\",\n  \"body\": \"Replacing the <value> tags with your appropriate values for the PushApps SDK key and Google project number.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Need the RTL version?\",\n  \"body\": \"Please see below the command for the RTL version.\"\n}\n[/block]\nFor LTR:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"cordova plugin add https://github.com/PushAppsPlatform/cordova-pushapps-sdk.git --variable PA_SDK_KEY=\\\"<value>\\\" --variable PA_GOOGLE_PROJECT_NUMBER=\\\"<value>\\\"\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nFor RTL:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"cordova plugin add https://github.com/PushAppsPlatform/cordova-pushapps-sdk-rtl.git --variable PA_SDK_KEY=\\\"<value>\\\" --variable PA_GOOGLE_PROJECT_NUMBER=\\\"<value>\\\"\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Android\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"That's it!\",\n  \"body\": \"If you only have Android as a platform - you're done with integrating PushApps. Pretty easy, right?! If you also need iOS, please follow the below instructions.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"iOS\"\n}\n[/block]\n1. Build your Xcode project, by running the following command:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"cordova build ios\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n2. Go to your app folder > platforms > ios > Open the \"xcworkspace\" file.\n\n3. Select your project, on the left panel:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/34078cf-Screen_Shot_2016-11-13_at_19.20.13.png\",\n        \"Screen Shot 2016-11-13 at 19.20.13.png\",\n        912,\n        1676,\n        \"#efeff0\"\n      ]\n    }\n  ]\n}\n[/block]\n4. Set your development team in the Signing section:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e7aea63-Screen_Shot_2017-01-16_at_10.41.35.png\",\n        \"Screen Shot 2017-01-16 at 10.41.35.png\",\n        1474,\n        826,\n        \"#222f43\"\n      ]\n    }\n  ]\n}\n[/block]\n5. Go to the `Capabilities` section and enable `Push Notifications`. Also, enable `App Groups` and make sure to create and select a string as the following (this string is unique per Apple account):\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5f2f9b4-Screen_Shot_2017-01-16_at_10.48.50.png\",\n        \"Screen Shot 2017-01-16 at 10.48.50.png\",\n        1798,\n        712,\n        \"#dbdbd9\"\n      ]\n    }\n  ]\n}\n[/block]\n6. Press on the + sign under the targets list (not on the left corner +). You should see a popup like the following:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8ca63f5-Screen_Shot_2016-11-13_at_19.21.19.png\",\n        \"Screen Shot 2016-11-13 at 19.21.19.png\",\n        1898,\n        1066,\n        \"#eaebeb\"\n      ]\n    }\n  ]\n}\n[/block]\n7. Choose the Notification Service Extension and give it a name (e.g. \"ServiceExtension\"). Select \"Activate\" if asked:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6e3a346-Screen_Shot_2016-11-13_at_19.22.39.png\",\n        \"Screen Shot 2016-11-13 at 19.22.39.png\",\n        1168,\n        514,\n        \"#e9e9e9\"\n      ]\n    }\n  ]\n}\n[/block]\n8. Choose the new created target and add PushApps to `Linked Frameworks and Libraries` (please keep other libraries in the list, if presented):\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7fa17cb-Screen_Shot_2017-01-16_at_10.50.22.png\",\n        \"Screen Shot 2017-01-16 at 10.50.22.png\",\n        1500,\n        396,\n        \"#dededd\"\n      ]\n    }\n  ]\n}\n[/block]\n9. In the `Capabilities` section for this target also enable `App Groups` and select the same string.\n\n10. You should now see a new folder in your project panel, with 3 new auto-created files:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/571103a-Screen_Shot_2016-11-13_at_19.23.51.png\",\n        \"Screen Shot 2016-11-13 at 19.23.51.png\",\n        528,\n        730,\n        \"#f2f2f2\"\n      ]\n    }\n  ]\n}\n[/block]\n11. Select the .h file and replace its code with the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import \\\"PushApps.h\\\"\\n\\n:::at:::interface NotificationService : PANotificationServiceExtension\\n\\n@end\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n12. Select the .m file and replace its code with the following:\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Please do not forget!\",\n  \"body\": \"To replace \\\"<YOUR_SDK_KEY>\\\" with your PushApps SDK key.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import \\\"NotificationService.h\\\"\\n\\n@implementation NotificationService\\n\\n- (instancetype)init\\n{\\n    self = [super init];\\n    if (self) {\\n        [self setPushAppsSdkKey:@\\\"<YOUR_SDK_KEY>\\\" andAppGroupName:@\\\"<YOUR_APP_GROUP_NAME>\\\"];\\n    }\\n    return self;\\n}\\n\\n\\n@end\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n13. Add to the .plist file the following exception for the PushApps domain:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<key>NSAppTransportSecurity</key>\\n\\t<dict>\\n\\t\\t<key>NSExceptionDomains</key>\\n\\t\\t<dict>\\n\\t\\t\\t<key>pushapps.mobi</key>\\n\\t\\t\\t<dict>\\n\\t\\t\\t\\t<key>NSIncludesSubdomains</key>\\n\\t\\t\\t\\t<true/>\\n\\t\\t\\t</dict>\\n\\t\\t</dict>\\n\\t</dict>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n14. Select your project file and press on the + sign under the targets list (not on the left corner +). Add `Notification Content Extension`. Make sure to enable `App Groups` and add PushApps to the linked frameworks list, as you did for the `Service Extension`.\n\n15. Remove the auto generated XIB file.\n\n16. Replace the content of the new .h file with the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import \\\"PushApps.h\\\"\\n\\n@interface NotificationViewController : PANotificationContentExtension\\n\\n@end\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n17. Replace the content of the new .m file with the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import \\\"NotificationViewController.h\\\"\\n\\n@implementation NotificationViewController\\n\\n- (instancetype)init\\n{\\n    self = [super init];\\n    if (self) {\\n        [self setPushAppsSdkKey:@\\\"<YOUR-SDK-KEY>\\\" andAppGroupName:@\\\"<YOUR-APP-GROUPS-NAME>\\\"];\\n    }\\n    return self;\\n}\\n\\n@end\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n18. In the .plist file, replace the `NSExtension` with the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<key>NSExtension</key>\\n    <dict>\\n        <key>NSExtensionAttributes</key>\\n        <dict>\\n            <key>UNNotificationExtensionDefaultContentHidden</key>\\n            <true/>\\n            <key>UNNotificationExtensionCategory</key>\\n            <array>\\n                <string>pushapps</string>\\n                <string>pushapps-recommendations</string>\\n            </array>\\n            <key>UNNotificationExtensionInitialContentSizeRatio</key>\\n            <integer>1</integer>\\n        </dict>\\n        <key>NSExtensionPrincipalClass</key>\\n        <string>NotificationViewController</string>\\n        <key>NSExtensionPointIdentifier</key>\\n        <string>com.apple.usernotifications.content-extension</string>\\n    </dict>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nPlease also add to the .plist the following key, to enable network requests for the PushApps servers:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<key>NSAppTransportSecurity</key>\\n\\t<dict>\\n\\t\\t<key>NSExceptionDomains</key>\\n\\t\\t<dict>\\n\\t\\t\\t<key>pushapps.mobi</key>\\n\\t\\t\\t<dict>\\n\\t\\t\\t\\t<key>NSIncludesSubdomains</key>\\n\\t\\t\\t\\t<true/>\\n\\t\\t\\t</dict>\\n\\t\\t</dict>\\n\\t</dict>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"That's it!\",\n  \"body\": \"You should now be able to run your Xcode project, directly to your device.\\nNow you're ready to start testing your app with PushApps. Please follow the [API Reference](doc:api-reference), for full documentation.\"\n}\n[/block]","excerpt":"","slug":"sdk-installation-1","type":"basic","title":"SDK Installation"}
1. Open the command line inside your app directory, and add the PushApps plugin: [block:callout] { "type": "danger", "title": "Do Not Forget!", "body": "Replacing the <value> tags with your appropriate values for the PushApps SDK key and Google project number." } [/block] [block:callout] { "type": "info", "title": "Need the RTL version?", "body": "Please see below the command for the RTL version." } [/block] For LTR: [block:code] { "codes": [ { "code": "cordova plugin add https://github.com/PushAppsPlatform/cordova-pushapps-sdk.git --variable PA_SDK_KEY=\"<value>\" --variable PA_GOOGLE_PROJECT_NUMBER=\"<value>\"", "language": "shell" } ] } [/block] For RTL: [block:code] { "codes": [ { "code": "cordova plugin add https://github.com/PushAppsPlatform/cordova-pushapps-sdk-rtl.git --variable PA_SDK_KEY=\"<value>\" --variable PA_GOOGLE_PROJECT_NUMBER=\"<value>\"", "language": "shell" } ] } [/block] [block:api-header] { "type": "basic", "title": "Android" } [/block] [block:callout] { "type": "success", "title": "That's it!", "body": "If you only have Android as a platform - you're done with integrating PushApps. Pretty easy, right?! If you also need iOS, please follow the below instructions." } [/block] [block:api-header] { "type": "basic", "title": "iOS" } [/block] 1. Build your Xcode project, by running the following command: [block:code] { "codes": [ { "code": "cordova build ios", "language": "shell" } ] } [/block] 2. Go to your app folder > platforms > ios > Open the "xcworkspace" file. 3. Select your project, on the left panel: [block:image] { "images": [ { "image": [ "https://files.readme.io/34078cf-Screen_Shot_2016-11-13_at_19.20.13.png", "Screen Shot 2016-11-13 at 19.20.13.png", 912, 1676, "#efeff0" ] } ] } [/block] 4. Set your development team in the Signing section: [block:image] { "images": [ { "image": [ "https://files.readme.io/e7aea63-Screen_Shot_2017-01-16_at_10.41.35.png", "Screen Shot 2017-01-16 at 10.41.35.png", 1474, 826, "#222f43" ] } ] } [/block] 5. Go to the `Capabilities` section and enable `Push Notifications`. Also, enable `App Groups` and make sure to create and select a string as the following (this string is unique per Apple account): [block:image] { "images": [ { "image": [ "https://files.readme.io/5f2f9b4-Screen_Shot_2017-01-16_at_10.48.50.png", "Screen Shot 2017-01-16 at 10.48.50.png", 1798, 712, "#dbdbd9" ] } ] } [/block] 6. Press on the + sign under the targets list (not on the left corner +). You should see a popup like the following: [block:image] { "images": [ { "image": [ "https://files.readme.io/8ca63f5-Screen_Shot_2016-11-13_at_19.21.19.png", "Screen Shot 2016-11-13 at 19.21.19.png", 1898, 1066, "#eaebeb" ] } ] } [/block] 7. Choose the Notification Service Extension and give it a name (e.g. "ServiceExtension"). Select "Activate" if asked: [block:image] { "images": [ { "image": [ "https://files.readme.io/6e3a346-Screen_Shot_2016-11-13_at_19.22.39.png", "Screen Shot 2016-11-13 at 19.22.39.png", 1168, 514, "#e9e9e9" ] } ] } [/block] 8. Choose the new created target and add PushApps to `Linked Frameworks and Libraries` (please keep other libraries in the list, if presented): [block:image] { "images": [ { "image": [ "https://files.readme.io/7fa17cb-Screen_Shot_2017-01-16_at_10.50.22.png", "Screen Shot 2017-01-16 at 10.50.22.png", 1500, 396, "#dededd" ] } ] } [/block] 9. In the `Capabilities` section for this target also enable `App Groups` and select the same string. 10. You should now see a new folder in your project panel, with 3 new auto-created files: [block:image] { "images": [ { "image": [ "https://files.readme.io/571103a-Screen_Shot_2016-11-13_at_19.23.51.png", "Screen Shot 2016-11-13 at 19.23.51.png", 528, 730, "#f2f2f2" ] } ] } [/block] 11. Select the .h file and replace its code with the following: [block:code] { "codes": [ { "code": "#import \"PushApps.h\"\n\n@interface NotificationService : PANotificationServiceExtension\n\n@end", "language": "objectivec" } ] } [/block] 12. Select the .m file and replace its code with the following: [block:callout] { "type": "danger", "title": "Please do not forget!", "body": "To replace \"<YOUR_SDK_KEY>\" with your PushApps SDK key." } [/block] [block:code] { "codes": [ { "code": "#import \"NotificationService.h\"\n\n@implementation NotificationService\n\n- (instancetype)init\n{\n self = [super init];\n if (self) {\n [self setPushAppsSdkKey:@\"<YOUR_SDK_KEY>\" andAppGroupName:@\"<YOUR_APP_GROUP_NAME>\"];\n }\n return self;\n}\n\n\n@end", "language": "objectivec" } ] } [/block] 13. Add to the .plist file the following exception for the PushApps domain: [block:code] { "codes": [ { "code": "<key>NSAppTransportSecurity</key>\n\t<dict>\n\t\t<key>NSExceptionDomains</key>\n\t\t<dict>\n\t\t\t<key>pushapps.mobi</key>\n\t\t\t<dict>\n\t\t\t\t<key>NSIncludesSubdomains</key>\n\t\t\t\t<true/>\n\t\t\t</dict>\n\t\t</dict>\n\t</dict>", "language": "xml" } ] } [/block] 14. Select your project file and press on the + sign under the targets list (not on the left corner +). Add `Notification Content Extension`. Make sure to enable `App Groups` and add PushApps to the linked frameworks list, as you did for the `Service Extension`. 15. Remove the auto generated XIB file. 16. Replace the content of the new .h file with the following: [block:code] { "codes": [ { "code": "#import \"PushApps.h\"\n\n@interface NotificationViewController : PANotificationContentExtension\n\n@end", "language": "objectivec" } ] } [/block] 17. Replace the content of the new .m file with the following: [block:code] { "codes": [ { "code": "#import \"NotificationViewController.h\"\n\n@implementation NotificationViewController\n\n- (instancetype)init\n{\n self = [super init];\n if (self) {\n [self setPushAppsSdkKey:@\"<YOUR-SDK-KEY>\" andAppGroupName:@\"<YOUR-APP-GROUPS-NAME>\"];\n }\n return self;\n}\n\n@end", "language": "objectivec" } ] } [/block] 18. In the .plist file, replace the `NSExtension` with the following: [block:code] { "codes": [ { "code": "<key>NSExtension</key>\n <dict>\n <key>NSExtensionAttributes</key>\n <dict>\n <key>UNNotificationExtensionDefaultContentHidden</key>\n <true/>\n <key>UNNotificationExtensionCategory</key>\n <array>\n <string>pushapps</string>\n <string>pushapps-recommendations</string>\n </array>\n <key>UNNotificationExtensionInitialContentSizeRatio</key>\n <integer>1</integer>\n </dict>\n <key>NSExtensionPrincipalClass</key>\n <string>NotificationViewController</string>\n <key>NSExtensionPointIdentifier</key>\n <string>com.apple.usernotifications.content-extension</string>\n </dict>", "language": "xml" } ] } [/block] Please also add to the .plist the following key, to enable network requests for the PushApps servers: [block:code] { "codes": [ { "code": "<key>NSAppTransportSecurity</key>\n\t<dict>\n\t\t<key>NSExceptionDomains</key>\n\t\t<dict>\n\t\t\t<key>pushapps.mobi</key>\n\t\t\t<dict>\n\t\t\t\t<key>NSIncludesSubdomains</key>\n\t\t\t\t<true/>\n\t\t\t</dict>\n\t\t</dict>\n\t</dict>", "language": "xml" } ] } [/block] [block:callout] { "type": "success", "title": "That's it!", "body": "You should now be able to run your Xcode project, directly to your device.\nNow you're ready to start testing your app with PushApps. Please follow the [API Reference](doc:api-reference), for full documentation." } [/block]