Customizing SDK

Background modes

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.

Notification alert in foreground

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

Controlling Log Level

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

Deep linking

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.

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.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
    NSString *page = components.host;
    NSString *promotionId = nil;
  
    //return if this is not a promotion deep link
    if(![page isEqualToString:@"promotion"])
        return NO;

    for(NSURLQueryItem *item in components.queryItems)
    {
        if([item.name isEqualToString:@"id"])
            promotionId = item.value;
    }
  
    PromoPageViewController *vc = [[PromoPageViewController alloc] init];
    vc.promotionId = promotionId
    [self presentViewController:vc animated:YES completion:nil];
}

In-Apps Tracking

In paymentQueue:updatedTransactions: delegate method call sendSKPaymentTransactions method of PushManager

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
  
  [[PushNotificationManager pushManager] sendSKPaymentTransactions:transactions];
  
  //the rest of the code, consume transactions, etc
}

Geozones push notifications

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.

Private Endpoint URL

Enterprise only.

Pushwoosh provides Private endpoints for Enterprise customers. To set up a Private endpoint for iOS SDK add the following to your Info.plist file

<key>Pushwoosh_BASEURL</key>
<string>PUSHWOOSH_PRIVATE_ENDPOINT_URL_PROVIDED</string>

Customizing SDK