{"_id":"5788a814dfd5433600683f3a","project":"5540ce1b31827a0d007ab1cc","__v":4,"parentDoc":null,"user":"55b8b82fdec1c9210013cfa1","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-15T09:08:36.090Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Background modes\"\n}\n[/block]\nTo ensure that Pushwoosh SDK always receives the push token it is highly recommended to enable the Remote notifications option from the Background modes section of the Capabilities tab in your Xcode project. You can also enable this support by including the `UIBackgroundModes` key with the `remote-notification` value in your app’s **Info.plist** file.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Notification alert in foreground\"\n}\n[/block]\nBy default Pushwoosh iOS SDK displays the notification banner when the app is running in the foreground.\nYou can control this behavior by changing the following flags in the **Info.plist**:\n\nFlag `Pushwoosh_ALERT_TYPE` – string type, values are:\n\n`BANNER` – default value, displays banner in-app alert\n`ALERT` – alert notification\n`NONE` – do not display a notification when the app is in the foreground\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Controlling Log Level\"\n}\n[/block]\nTo assist with debugging and integration, SDK will print all requests to the console by default. When you are ready for the production build, set \"Pushwoosh_LOG_LEVEL\" string key in your **Info.plist** file to one of the following values, depending on how much you want to see:\n\n`NONE` - No logs from SDK\n`ERROR` - Only display errors in console\n`WARNING` - Also display warnings\n`INFO` - Add informational messages\n`DEBUG` - Add debug information\n`VERBOSE` - Everything SDK can print and more\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Deep linking\"\n}\n[/block]\nIn your **Info.plist** file add `URL types` array with `URL Identifier` and `URL Scheme`.\nIn the example below the `URL Scheme` is *com.pushwoosh* and the `URL Identifier` is *promotion*.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/wKjoyjdtSwWVwKDP9zLX_PushNotificationsApp-Info_plist.png\",\n        \"PushNotificationsApp-Info_plist.png\",\n        \"1754\",\n        \"178\",\n        \"#984c1e\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIn your App Delegate file (usually *AppDelegate.m*) add openURL delegate function as outlined in the example below. The example checks for the correct page, parses \"id\" value from the URL and opens PromoPageViewController in response.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\\n    NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];\\n    NSString *page = components.host;\\n    NSString *promotionId = nil;\\n  \\n    //return if this is not a promotion deep link\\n    if(![page isEqualToString::::at:::\\\"promotion\\\"])\\n        return NO;\\n\\n    for(NSURLQueryItem *item in components.queryItems)\\n    {\\n        if([item.name isEqualToString:@\\\"id\\\"])\\n            promotionId = item.value;\\n    }\\n  \\n    PromoPageViewController *vc = [[PromoPageViewController alloc] init];\\n    vc.promotionId = promotionId\\n    [self presentViewController:vc animated:YES completion:nil];\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"In-Apps Tracking\"\n}\n[/block]\nIn `paymentQueue:updatedTransactions: delegate` method call `sendSKPaymentTransactions method` of `PushManager`\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {\\n  \\n  [[PushNotificationManager pushManager] sendSKPaymentTransactions:transactions];\\n  \\n  //the rest of the code, consume transactions, etc\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Geozones push notifications\"\n}\n[/block]\n**1.** Add one of the following keys to your Info.plist:\n\n* `NSLocationAlwaysUsageDescription` – for app to track Geozones at all times;\n* `NSLocationWhenInUseUsageDescription` – for app to track Geozones only while running in the foreground.\n\n**2.** Start Geozone tracking when needed with `[[PushNotificationManager pushManager] startLocationTracking];`\n\nRequired actions to enable GPS usage:\n\n  * Use GPS when the app is in the foreground – add `PW_USE_GPS` flag to **Info.plist**;\n  * Use GPS when the app is in the background – go to **Target – Capabilities – Background modes – enable Location updates**.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Private Endpoint URL\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Enterprise only.\",\n  \"body\": \"\"\n}\n[/block]\nPushwoosh provides Private endpoints for Enterprise customers. To set up a Private endpoint for iOS SDK add the following to your Info.plist file\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<key>Pushwoosh_BASEURL</key>\\n<string>PUSHWOOSH_PRIVATE_ENDPOINT_URL_PROVIDED</string>\",\n      \"language\": \"xml\",\n      \"name\": \"Info.plist\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"customizing-ios-sdk","type":"basic","title":"Customizing SDK"}
[block:api-header] { "type": "basic", "title": "Background modes" } [/block] To ensure that Pushwoosh SDK always receives the push token it is highly recommended to enable the Remote notifications option from the Background modes section of the Capabilities tab in your Xcode project. You can also enable this support by including the `UIBackgroundModes` key with the `remote-notification` value in your app’s **Info.plist** file. [block:api-header] { "type": "basic", "title": "Notification alert in foreground" } [/block] By default Pushwoosh iOS SDK displays the notification banner when the app is running in the foreground. You can control this behavior by changing the following flags in the **Info.plist**: Flag `Pushwoosh_ALERT_TYPE` – string type, values are: `BANNER` – default value, displays banner in-app alert `ALERT` – alert notification `NONE` – do not display a notification when the app is in the foreground [block:api-header] { "type": "basic", "title": "Controlling Log Level" } [/block] To assist with debugging and integration, SDK will print all requests to the console by default. When you are ready for the production build, set "Pushwoosh_LOG_LEVEL" string key in your **Info.plist** file to one of the following values, depending on how much you want to see: `NONE` - No logs from SDK `ERROR` - Only display errors in console `WARNING` - Also display warnings `INFO` - Add informational messages `DEBUG` - Add debug information `VERBOSE` - Everything SDK can print and more [block:api-header] { "type": "basic", "title": "Deep linking" } [/block] In your **Info.plist** file add `URL types` array with `URL Identifier` and `URL Scheme`. In the example below the `URL Scheme` is *com.pushwoosh* and the `URL Identifier` is *promotion*. [block:image] { "images": [ { "image": [ "https://files.readme.io/wKjoyjdtSwWVwKDP9zLX_PushNotificationsApp-Info_plist.png", "PushNotificationsApp-Info_plist.png", "1754", "178", "#984c1e", "" ] } ] } [/block] In your App Delegate file (usually *AppDelegate.m*) add openURL delegate function as outlined in the example below. The example checks for the correct page, parses "id" value from the URL and opens PromoPageViewController in response. [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\n NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];\n NSString *page = components.host;\n NSString *promotionId = nil;\n \n //return if this is not a promotion deep link\n if(![page isEqualToString:@\"promotion\"])\n return NO;\n\n for(NSURLQueryItem *item in components.queryItems)\n {\n if([item.name isEqualToString:@\"id\"])\n promotionId = item.value;\n }\n \n PromoPageViewController *vc = [[PromoPageViewController alloc] init];\n vc.promotionId = promotionId\n [self presentViewController:vc animated:YES completion:nil];\n}", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "In-Apps Tracking" } [/block] In `paymentQueue:updatedTransactions: delegate` method call `sendSKPaymentTransactions method` of `PushManager` [block:code] { "codes": [ { "code": "- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {\n \n [[PushNotificationManager pushManager] sendSKPaymentTransactions:transactions];\n \n //the rest of the code, consume transactions, etc\n}", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Geozones push notifications" } [/block] **1.** Add one of the following keys to your Info.plist: * `NSLocationAlwaysUsageDescription` – for app to track Geozones at all times; * `NSLocationWhenInUseUsageDescription` – for app to track Geozones only while running in the foreground. **2.** Start Geozone tracking when needed with `[[PushNotificationManager pushManager] startLocationTracking];` Required actions to enable GPS usage: * Use GPS when the app is in the foreground – add `PW_USE_GPS` flag to **Info.plist**; * Use GPS when the app is in the background – go to **Target – Capabilities – Background modes – enable Location updates**. [block:api-header] { "type": "basic", "title": "Private Endpoint URL" } [/block] [block:callout] { "type": "success", "title": "Enterprise only.", "body": "" } [/block] Pushwoosh provides Private endpoints for Enterprise customers. To set up a Private endpoint for iOS SDK add the following to your Info.plist file [block:code] { "codes": [ { "code": "<key>Pushwoosh_BASEURL</key>\n<string>PUSHWOOSH_PRIVATE_ENDPOINT_URL_PROVIDED</string>", "language": "xml", "name": "Info.plist" } ] } [/block]