WonderPush Class Reference

Inherits from NSObject
Declared in WonderPush.h

Overview

WonderPush is your main interface to the WonderPush SDK.

Make sure you properly installed the WonderPush SDK, as described in the guide.

You must call setClientId:secret: before using any other method. You must also either call setupDelegateForApplication:, preferably in the application:willFinishLaunchingWithOptions: method of your AppDelegate just after calling the previously mentioned method, or override every method listed under Manual AppDelegate forwarding.

Troubleshooting tip: As the SDK should not interfere with your application other than when a notification is to be shown, make sure to monitor your logs for WonderPush output during development, if things did not went as smoothly as they should have.

Initialization

+ setClientId:secret:

Initializes the WonderPush SDK.

+ (void)setClientId:(NSString *)clientId secret:(NSString *)secret

Parameters

clientId

Your WonderPush client id

secret

Your WonderPush client secret

Discussion

Initializes the WonderPush SDK.

Initialization should occur at the earliest possible time, when your application starts. A good place is the application:didFinishLaunchingWithOptions: method of your AppDelegate.

Please refer to the step entitled Initialize the SDK from the guide.

Declared In

WonderPush.h

+ setUserId:

Sets the user id, used to identify a single identity across multiple devices, and to correctly identify multiple users on a single device.

+ (void)setUserId:(NSString *)userId

Parameters

userId

The user id, unique to your application. Use nil for anonymous users. You are strongly encouraged to use your own unique internal identifier.

Discussion

Sets the user id, used to identify a single identity across multiple devices, and to correctly identify multiple users on a single device.

If not called, the last used user id it assumed. Defaulting to nil if none is known.

Prefer calling this method just before calling setClientId:secret:, rather than just after. Upon changing userId, the access token is wiped, so avoid unnecessary calls, like calling with null just before calling with a user id.

Declared In

WonderPush.h

+ isInitialized

Returns whether the WonderPush SDK has been given the clientId and clientSecret. Will be YES as soon as [WonderPush setClientId:secret:] is called. No network can be performed before the SDK is initialized. Further use of the SDK methods will be dropped until initialized. Such call will be ignored and logged in the device console.

+ (BOOL)isInitialized

Return Value

The initialization state as a BOOL

Discussion

Returns whether the WonderPush SDK has been given the clientId and clientSecret. Will be YES as soon as [WonderPush setClientId:secret:] is called. No network can be performed before the SDK is initialized. Further use of the SDK methods will be dropped until initialized. Such call will be ignored and logged in the device console.

Declared In

WonderPush.h

+ isReady

Returns whether the WonderPush SDK is ready to operate. Returns YES when the WP_NOTIFICATION_INITIALIZED is sent.

+ (BOOL)isReady

Return Value

The initialization state as a BOOL

Discussion

Returns whether the WonderPush SDK is ready to operate. Returns YES when the WP_NOTIFICATION_INITIALIZED is sent.

Declared In

WonderPush.h

+ setLogging:

Controls SDK logging.

+ (void)setLogging:(BOOL)enable

Parameters

enable

Whether to enable logs.

Discussion

Controls SDK logging.

Declared In

WonderPush.h

Core information

+ userId

Returns the userId currently in use, nil by default.

+ (NSString *)userId

Discussion

Returns the userId currently in use, nil by default.

Declared In

WonderPush.h

+ installationId

Returns the installationId identifying your application on a device, bond to a specific userId. If you want to store this information on your servers, keep the corresponding userId with it. Will return nil until the SDK is properly initialized.

+ (NSString *)installationId

Discussion

Returns the installationId identifying your application on a device, bond to a specific userId. If you want to store this information on your servers, keep the corresponding userId with it. Will return nil until the SDK is properly initialized.

Declared In

WonderPush.h

+ deviceId

Returns the unique device identifier.

+ (NSString *)deviceId

Discussion

Returns the unique device identifier.

Declared In

WonderPush.h

+ pushToken

Returns the push token, or device token in Apple lingo. Returns nil if the user is not opt-in.

+ (NSString *)pushToken

Discussion

Returns the push token, or device token in Apple lingo. Returns nil if the user is not opt-in.

Declared In

WonderPush.h

+ accessToken

Returns the currently used access token. Returns nil until the SDK is properly initialized. This together with your client secret gives entire control to the current installation and associated user, you should not disclose it unnecessarily.

+ (NSString *)accessToken

Discussion

Returns the currently used access token. Returns nil until the SDK is properly initialized. This together with your client secret gives entire control to the current installation and associated user, you should not disclose it unnecessarily.

Declared In

WonderPush.h

Push Notification handling

+ getNotificationEnabled

Returns whether the notifications are enabled.

+ (BOOL)getNotificationEnabled

Discussion

Returns whether the notifications are enabled.

Defaults to NO as notifications are opt-in on iOS.

Declared In

WonderPush.h

+ setNotificationEnabled:

Activates or deactivates the push notification on the device (if the user accepts) and registers the device token with WondePush.

+ (void)setNotificationEnabled:(BOOL)enabled

Parameters

enabled

The new activation state of push notifications.

Discussion

Activates or deactivates the push notification on the device (if the user accepts) and registers the device token with WondePush.

You must call the following method at least once to make the user pushable.

  • You can call this method multiple times. The user is only prompted for permission by iOS once.
  • Calling with YES opts the user in, whether he was not opt-in or soft opt-out (by calling with NO).
  • There is no need to call this method if the permission has already been granted, but it does not harm either. Prior to WonderPush iOS SDK v1.2.1.0, you should call it if the user was already opt-in in a non WonderPush-enabled version of your application.
  • If the permission has been denied, calling this method cannot opt the user back in as iOS leaves the user in control, through the system settings.

Because you only have one chance for prompting the user, you should find a good timing for that. For a start, you can systematically call it when the application starts, so that the user will be prompted directly at the first launch.

Declared In

WonderPush.h

+ isNotificationForWonderPush:

Returns whether the given notification is to be consumed by the WonderPush SDK.

+ (BOOL)isNotificationForWonderPush:(NSDictionary *)userInfo

Parameters

userInfo

The notification dictionary as read from some UIApplicationDelegate method parameters.

Discussion

Returns whether the given notification is to be consumed by the WonderPush SDK.

Declared In

WonderPush.h

+ isDataNotification:

Returns whether the notification is a data notification sent by WonderPush.

+ (BOOL)isDataNotification:(NSDictionary *)userInfo

Parameters

userInfo

The notification dictionary as read from some UIApplicationDelegate method parameters.

Discussion

Returns whether the notification is a data notification sent by WonderPush.

Data notifications are aimed at providing your application with some data your should consume accordingly.

Declared In

WonderPush.h

Installation data and events

+ getInstallationCustomProperties

Returns the latest known custom properties attached to the current installation object stored by WonderPush.

+ (NSDictionary *)getInstallationCustomProperties

Discussion

Returns the latest known custom properties attached to the current installation object stored by WonderPush.

Declared In

WonderPush.h

+ putInstallationCustomProperties:

Updates the custom properties attached to the current installation object stored by WonderPush.

+ (void)putInstallationCustomProperties:(NSDictionary *)customProperties

Parameters

customProperties

The partial object containing only the properties to update.

Discussion

Updates the custom properties attached to the current installation object stored by WonderPush.

In order to remove a value, don’t forget to use [NSNull null] as value.

Declared In

WonderPush.h

+ trackEvent:

Send an event to be tracked to WonderPush.

+ (void)trackEvent:(NSString *)type

Parameters

type

The event type, or name. Event types starting with an @ character are reserved.

Discussion

Send an event to be tracked to WonderPush.

Declared In

WonderPush.h

+ trackEvent:withData:

Send an event to be tracked to WonderPush.

+ (void)trackEvent:(NSString *)type withData:(NSDictionary *)data

Parameters

type

The event type, or name. Event types starting with an @ character are reserved.

data

A dictionary containing custom properties to be attached to the event. Prefer using a few custom properties over a plethora of event type variants. The keys should be prefixed according to the type of their values. You can find the details here: http://www.wonderpush.com/docs/guide/custom-fields

Discussion

Send an event to be tracked to WonderPush.

Declared In

WonderPush.h

Automatic AppDelegate forwarding

+ setupDelegateForApplication:

Setup UIApplicationDelegate override, so that calls from your UIApplicationDelegate are automatically transmitted to the WonderPush SDK.

+ (void)setupDelegateForApplication:(UIApplication *)application

Parameters

application

The application parameter from your AppDelegate.

Discussion

Setup UIApplicationDelegate override, so that calls from your UIApplicationDelegate are automatically transmitted to the WonderPush SDK.

This eases your setup, you can call this from your - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions method.

Declared In

WonderPush.h

Manual AppDelegate forwarding

+ application:didFinishLaunchingWithOptions:

Forwards an application delegate to the SDK.

+ (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Parameters

application

Same parameter as in the forwarded delegate method.

launchOptions

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

Method to call in your application:didFinishLaunchingWithOptions: method of your AppDelegate.

Declared In

WonderPush.h

+ application:didReceiveRemoteNotification:

Forwards an application delegate to the SDK.

+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

Parameters

application

Same parameter as in the forwarded delegate method.

userInfo

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

Method to call in your application:didReceiveRemoteNotification: method of your AppDelegate.

Declared In

WonderPush.h

+ application:didRegisterForRemoteNotificationsWithDeviceToken:

Forwards an application delegate to the SDK.

+ (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

Parameters

application

Same parameter as in the forwarded delegate method.

deviceToken

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

Method to call in your application:didRegisterForRemoteNotificationsWithDeviceToken: method of your AppDelegate.

Declared In

WonderPush.h

+ application:didFailToRegisterForRemoteNotificationsWithError:

Forwards an application delegate to the SDK.

+ (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error

Parameters

application

Same parameter as in the forwarded delegate method.

error

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

Method to call in your application:didFailToRegisterForRemoteNotificationsWithError: method of your AppDelegate.

Any previous device token will be forgotten.

Declared In

WonderPush.h

+ application:didReceiveLocalNotification:

Forwards an application delegate to the SDK.

+ (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

Parameters

application

Same parameter as in the forwarded delegate method.

notification

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

If your application uses backgroundModes/remote-notification, call this method in your application:didReceiveLocalNotification: method of your AppDelegate. Handles a notification and presents the associated dialog.

Declared In

WonderPush.h

+ application:didReceiveRemoteNotification:fetchCompletionHandler:

Forwards an application delegate to the SDK.

+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void ( ^ ) ( UIBackgroundFetchResult ))completionHandler

Parameters

application

Same parameter as in the forwarded delegate method.

userInfo

Same parameter as in the forwarded delegate method.

completionHandler

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

If your application uses backgroundModes/remote-notification, call this method in your application:didReceiveRemoteNotification:fetchCompletionHandler: method.

If you implement this application delegate function, you must call completionHandler at some point. If you do not know what to do, you’re probably good with calling it right away.

Declared In

WonderPush.h

+ applicationDidBecomeActive:

Forwards an application delegate to the SDK.

+ (void)applicationDidBecomeActive:(UIApplication *)application

Parameters

application

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

Method to call in your applicationDidBecomeActive: method of your AppDelegate.

Declared In

WonderPush.h

+ applicationDidEnterBackground:

Forwards an application delegate to the SDK.

+ (void)applicationDidEnterBackground:(UIApplication *)application

Parameters

application

Same parameter as in the forwarded delegate method.

Discussion

Forwards an application delegate to the SDK.

Method to call in your applicationDidEnterBackground: method of your AppDelegate.

Declared In

WonderPush.h