Advanced integration guide
This section provides information on advanced integration of the Pushwoosh iOS SDK.
Background modes
To enable this functionality, you must add Background Modes to your project.
Steps to enable background modes
- Open your project in Xcode and select it in the Project Navigator.
- Choose your app target from the left panel.
- Navigate to the Signing & Capabilities tab.
- Click the + Capability button in the upper-left corner.
- Search for and select Background Modes from the list.
- In the Background Modes section, enable Remote notifications by checking the box.
Once completed, your app will be able to handle push notifications, including silent ones, while running in the background.
Foreground modes
By default, Pushwoosh iOS SDK displays the notification banner when the app is running in the foreground.
You can control this behavior by setting the following boolean flag in your code (i.e., in your AppDelegate
):
// Set false to disable foreground notifications, true to enable itPushwoosh.sharedInstance().showPushnotificationAlert = true
// Set 0 to disable foreground notifications, 1 to enable it[[Pushwoosh sharedInstance] setShowPushnotificationAlert:0];
Log level
The Pushwoosh iOS SDK supports the following logging levels:
NONE
- No logs from SDK.ERROR
- Displays only error messages in the console.WARNING
- Displays warnings in addition to errors.INFO
- Includes informational messages (default setting).DEBUG
- Includes detailed debug information.
By default, the logging level is set to INFO, ensuring the SDK provides relevant information without cluttering the developer console.
To modify the logging level, update the Pushwoosh_LOG_LEVEL
key in your app’s Info.plist
file:
<key>Pushwoosh_LOG_LEVEL</key><string>YOUR_LOG_LEVEL</string>
Replace YOUR_LOG_LEVEL
with the desired level (e.g., DEBUG
or ERROR
).
Custom UNNotificationCenterDelegate
If you want to use your own UNNotificationCenterDelegate
(for example, for local notifications), you should inform Pushwoosh SDK about it for proper behavior. You can do it with the notificationCenterDelegateProxy
property of the Pushwoosh instance:
Pushwoosh.sharedInstance()?.notificationCenterDelegateProxy.add(my_delegate)
[Pushwoosh.sharedInstance.notificationCenterDelegateProxy addNotificationCenterDelegate:my_delegate];
Then, implement UNNotificationCenterDelegate
methods in your delegate:
func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { if (!PWMessage.isPushwooshMessage(notification.request.content.userInfo)) { // Handle your notification completionHandler(UNNotificationPresentationOptions.alert) }}
func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if (!PWMessage.isPushwooshMessage(response.notification.request.content.userInfo)) { // Handle your notification completionHandler() }}
- (void)userNotificationCenter:(UNNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { if (![PWMessage isPushwooshMessage:notification.request.content.userInfo]) { // Handle your message completionHandler(UNNotificationPresentationOptionAlert); }}
- (void)userNotificationCenter:(UNNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { if (![PWMessage.isPushwooshMessage:response.notification.request.content.userInfo]) { // Handle your message completionHandler(); }}
Pushwoosh Lazy Initialization
The Pushwoosh_LAZY_INITIALIZATION
flag prevents the automatic initialization of the Pushwoosh SDK when the application starts. This allows for more control over when the Pushwoosh SDK services are started.
When this flag is enabled, the Pushwoosh SDK does not start its services until Pushwoosh iOS SDK methods are explicitly called.
Add the following entry to Info.plist:
<key>Pushwoosh_LAZY_INITIALIZATION</key><true/>
Use Cases
-
Controlled SDK Initialization – The Pushwoosh_LAZY_INITIALIZATION flag allows delaying the Pushwoosh SDK startup, giving more control over when push services are activated.
-
Deferred Push Activation – In some applications, push notifications should only be initialized under specific conditions. Enabling this flag ensures that the Pushwoosh SDK starts only when explicitly requested.
-
User-Specific Push Configuration – Some applications may require customizing push notification settings based on user preferences or account settings. With lazy initialization, the Pushwoosh SDK starts only after the appropriate configuration is determined.
Complete list of Info.plist properties
Property | Description | Possible Values |
---|---|---|
Pushwoosh_APPID | Sets the Pushwoosh application ID for production build. | XXXXX-XXXXX Type: String |
Pushwoosh_APPID_Dev | Sets the Pushwoosh application ID for development build. | XXXXX-XXXXX Type: String |
Pushwoosh_SHOW_ALERT | Shows notification foreground alert. | YES (default) / NO Type: Boolean |
Pushwoosh_ALERT_TYPE | Sets the notification alert style. | BANNER (default) / ALERT / NONE Type: String |
Pushwoosh_BASEURL | Overrides the Pushwoosh server base URL. | https://cp.pushwoosh.com/json/1.3/ (default) Type: String |
Pushwoosh_AUTO_ACCEPT_DEEP_LINK_FOR_SILENT_PUSH | If YES , Deep Links received in silent pushes will be processed automatically. | YES (default) / NO Type: Boolean |
Pushwoosh_ALLOW_SERVER_COMMUNICATION | Allows the SDK to send network requests to Pushwoosh servers. | YES (default) / NO Type: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_DATA | Allows the SDK to collect and send device data (OS version, locale, and model) to the server. | YES (default) / NO Type: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_OS_VERSION | Allows the SDK to collect and send the device’s OS version to the server. | YES (default) / NO Type: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_LOCALE | Allows the SDK to collect and send the device locale to the server. | YES (default) / NO Type: Boolean |
Pushwoosh_ALLOW_COLLECTING_DEVICE_MODEL | Allows the SDK to collect and send the device model to the server. | YES (default) / NO Type: Boolean |
Pushwoosh_LOG_LEVEL | Pushwoosh SDK logging level. For details, refer to Controlling Log Level. | NONE / ERROR / WARNING / INFO (default) / DEBUG / VERBOSE Type: String |
Pushwoosh_PURCHASE_TRACKING_ENABLED | Allows the SDK to track in-app purchases. Needed for Customer Journey Builder. | YES / NO (default) Type: Boolean |