{"_id":"56ea7bdfcf35bf0e00adb91d","project":"56cecbdb44c5700b0095c03a","user":"56cecbb2e50c9c1b008303eb","parentDoc":null,"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":"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":"","__v":14,"metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-03-17T09:41:51.287Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Deprecated\",\n  \"body\": \"This is are the instructions for our SDK previous to the release of iOS 10. Please refer to our [iOS SDK installation](doc:ios-sdk-installation) for the latests version.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"We strongly recommend to set your APNS credentials in the PushApps Admin Console, before integrating the PushApps SDK. <a target=\\\"_blank\\\" href=\\\"https://docs.pushapps.mobi/v1.0/docs/setup-your-push-notifications-credentials\\\">Please check our guide for that</a>.\",\n  \"title\": \"Before you begin...\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Add PushApps SDK To Your Project\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"CocoaPods\",\n  \"body\": \"If you're using CocoaPods, you can add PushApps SDK to your project by adding the following line to your pod file:\\n```pod 'PushApps'```\\nYou can now go to [Step 2](#2-update-project-settings) in this guide.\"\n}\n[/block]\n1.1 Download the [PushApps SDK](https://s3.amazonaws.com/pushapps-sdk/ios/PushApps.framework.zip) and unzip it.\n\n1.2 In you Xcode project, go to `Embedded Binaries` section and click the `+` button. Click on `Add Other` and navigate to the downloaded folder. Choose the `PushApps.framework` file.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Update Project Settings\"\n}\n[/block]\n2.1 If your on iOS 9 or above, Add the domain `pushapps.mobi` to your `NSExceptionDomains` dictionary, according to the image below:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/OXR0UdotRm2EoOYSgm2u_Screen%20Shot%202016-04-07%20at%2010.27.52%20AM.png\",\n        \"Screen Shot 2016-04-07 at 10.27.52 AM.png\",\n        \"786\",\n        \"132\",\n        \"#913d2d\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2.2 Add the following URL Scheme into your info.plist file. Don't forget to replace <YOUR-SDK-KEY> with your \"real\" PushApps SDK key for your app.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/CDD0Q0DcSDWZvytkOmDa_Screen%20Shot%202016-05-29%20at%205.40.31%20PM.png\",\n        \"Screen Shot 2016-05-29 at 5.40.31 PM.png\",\n        \"762\",\n        \"164\",\n        \"#8e3e27\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Using Advertisement Id\",\n  \"body\": \"PushApps will check if your project contains the AdSupport.framework and will use the advertisement id for all it's requests. If no, the vendor identifier will be use.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Add Some Code\"\n}\n[/block]\n3.1 Inside your AppDelegate.m add the following line to your imports list:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <PushApps/PushApps.h>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.2. At the end of your `didFinishLaunchingWithOptions` method, add the following line (don't forget to replace the string \"PushApps_Sdk_Key\" with your SDK key):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\\n    [PushApps registerDeviceWithSdkKey::::at:::\\\"PushApps_Sdk_Key\\\"];\\n    return YES;\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.3 To register your app users to receive push notifications, call the following line:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[PushApps registerForPushNotifications:launchOptions];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.4 Add the following methods, in your AppDelegate.m:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\\n{\\n    [PushApps setDevicePushToken:deviceToken];\\n}\\n\\n-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\\n{\\n    if ([userInfo objectForKey:@\\\"n_id\\\"]) {\\n        [PushApps handleNotification:userInfo];\\n    } else {\\n        // Your external push provider code goes here...\\n    }\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"That's it!\",\n  \"body\": \"Try to compile your app with the right provision profile (otherwise you won't receive push notifications). In order to test your code, go to PushApps admin console and start sending notifications!\"\n}\n[/block]","excerpt":"","slug":"sdk-installation-manual-previous","type":"basic","title":"Previous version - SDK installation"}

Previous version - SDK installation


[block:callout] { "type": "danger", "title": "Deprecated", "body": "This is are the instructions for our SDK previous to the release of iOS 10. Please refer to our [iOS SDK installation](doc:ios-sdk-installation) for the latests version." } [/block] [block:callout] { "type": "info", "body": "We strongly recommend to set your APNS credentials in the PushApps Admin Console, before integrating the PushApps SDK. <a target=\"_blank\" href=\"https://docs.pushapps.mobi/v1.0/docs/setup-your-push-notifications-credentials\">Please check our guide for that</a>.", "title": "Before you begin..." } [/block] [block:api-header] { "type": "basic", "title": "1. Add PushApps SDK To Your Project" } [/block] [block:callout] { "type": "info", "title": "CocoaPods", "body": "If you're using CocoaPods, you can add PushApps SDK to your project by adding the following line to your pod file:\n```pod 'PushApps'```\nYou can now go to [Step 2](#2-update-project-settings) in this guide." } [/block] 1.1 Download the [PushApps SDK](https://s3.amazonaws.com/pushapps-sdk/ios/PushApps.framework.zip) and unzip it. 1.2 In you Xcode project, go to `Embedded Binaries` section and click the `+` button. Click on `Add Other` and navigate to the downloaded folder. Choose the `PushApps.framework` file. [block:api-header] { "type": "basic", "title": "2. Update Project Settings" } [/block] 2.1 If your on iOS 9 or above, Add the domain `pushapps.mobi` to your `NSExceptionDomains` dictionary, according to the image below: [block:image] { "images": [ { "image": [ "https://files.readme.io/OXR0UdotRm2EoOYSgm2u_Screen%20Shot%202016-04-07%20at%2010.27.52%20AM.png", "Screen Shot 2016-04-07 at 10.27.52 AM.png", "786", "132", "#913d2d", "" ] } ] } [/block] 2.2 Add the following URL Scheme into your info.plist file. Don't forget to replace <YOUR-SDK-KEY> with your "real" PushApps SDK key for your app. [block:image] { "images": [ { "image": [ "https://files.readme.io/CDD0Q0DcSDWZvytkOmDa_Screen%20Shot%202016-05-29%20at%205.40.31%20PM.png", "Screen Shot 2016-05-29 at 5.40.31 PM.png", "762", "164", "#8e3e27", "" ] } ] } [/block] [block:callout] { "type": "warning", "title": "Using Advertisement Id", "body": "PushApps will check if your project contains the AdSupport.framework and will use the advertisement id for all it's requests. If no, the vendor identifier will be use." } [/block] [block:api-header] { "type": "basic", "title": "3. Add Some Code" } [/block] 3.1 Inside your AppDelegate.m add the following line to your imports list: [block:code] { "codes": [ { "code": "#import <PushApps/PushApps.h>", "language": "objectivec" } ] } [/block] 3.2. At the end of your `didFinishLaunchingWithOptions` method, add the following line (don't forget to replace the string "PushApps_Sdk_Key" with your SDK key): [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n [PushApps registerDeviceWithSdkKey:@\"PushApps_Sdk_Key\"];\n return YES;\n}", "language": "objectivec" } ] } [/block] 3.3 To register your app users to receive push notifications, call the following line: [block:code] { "codes": [ { "code": "[PushApps registerForPushNotifications:launchOptions];", "language": "objectivec" } ] } [/block] 3.4 Add the following methods, in your AppDelegate.m: [block:code] { "codes": [ { "code": "-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n [PushApps setDevicePushToken:deviceToken];\n}\n\n-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\n{\n if ([userInfo objectForKey:@\"n_id\"]) {\n [PushApps handleNotification:userInfo];\n } else {\n // Your external push provider code goes here...\n }\n}", "language": "objectivec" } ] } [/block] [block:callout] { "type": "success", "title": "That's it!", "body": "Try to compile your app with the right provision profile (otherwise you won't receive push notifications). In order to test your code, go to PushApps admin console and start sending notifications!" } [/block]