Inherits from NSObject
Declared in PWAlerts.h

Overview

PWAlerts enables easy implementation of alerts and notifications. It encapsulates advanced push features like subscriber groups and the ability to fetch extra information related to a push notification.

Alert Segments

PWAlerts allows you to provide users with a hierarchy of alert segments from which one or more filtered alerts and notifications can be received. There are two methods that facilitate this: getAlertSegmentsWithSuccess:failure: and updateAlertSegments:success:failure:.

Development

During the development of your application, you may want to utilize Apple’s push notification sandbox. To enable development mode for PWAlerts, would call [PWAlerts setDevelopmentModeEnabled:YES]. If you omit this call, PWAlerts will default to Apple’s production push notification system.

Class Methods

APNSToken

Returns the Apple Push Notification service (APNs) token. Call this after didRegisterForRemoteNotificationsWithDeviceToken:.

+ (NSString *__nullable)APNSToken

Discussion

Calling this method prior to registering for remote notifications will return nil.

Declared In

PWAlerts.h

alertsEnabled

A Boolean value indicating whether Phunware alerts are enabled on the device.

+ (BOOL)alertsEnabled

Discussion

Alerts are enabled by default. Developers can opt-out of Phunware remote notifications by calling [PWAlerts disableAlerts]. Developers can opt back in to Phunware alerts by calling [PWAlerts enableAlerts].

Declared In

PWAlerts.h

didFailToRegisterForRemoteNotificationsWithError:

Call this inside application:didFailToRegisterForRemoteNotificationsWithError:.

+ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *__nonnull)error

Parameters

error

An NSError object that encapsulates information explaining why registration did not succeed. The application can display this information to the user.

Declared In

PWAlerts.h

didReceiveRemoteNotification:

Called inside application:didReceiveRemoteNotification:. This method assumes all notifications received were opened by the user and triggers a push analytics payload.

+ (void)didReceiveRemoteNotification:(NSDictionary *__nonnull)userInfo

Parameters

userInfo

A dictionary that contains information related to the remote notification (specifically, a badge number for the application icon, a notification identifier and possibly custom data). The provider originates it as a JSON-defined dictionary that AppKit converts to an NSDictionary object. The dictionary may contain only property-list objects plus NSNull.

Declared In

PWAlerts.h

didReceiveRemoteNotificationForPushID:

Called to explicitly trigger a push analytics event. This method should only be called when the user consumes a push notification.

+ (void)didReceiveRemoteNotificationForPushID:(NSString *__nonnull)pushID

Parameters

pushID

The remote notification pushID. The pushID can be found in the application:didReceiveRemoteNotification: userInfo, `[userInfo objectForKey:@“pid”].

Declared In

PWAlerts.h

didRegisterForRemoteNotificationsWithDeviceToken:

Call this inside application:didRegisterForRemoteNotificationsWithDeviceToken:.

+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *__nonnull)devToken

Parameters

devToken

A token that identifies the device to Apple Push Notification service (APNS). The provider needs the token to be an opaque data type in order to submit it to the APNs servers when sending a notification to a device. For performance reasons, the APNs servers require a binary format.

Declared In

PWAlerts.h

disableAlerts

Opt user out of all Phunware alerts.

+ (void)disableAlerts

Discussion

to opt the user in to Phunware alerts again please use [PWAlerts enableAlerts]. Disabling alerts when they are already disabled is a no-op.

Declared In

PWAlerts.h

enableAlerts

Opt-in user to Phunware alerts.

+ (void)enableAlerts

Discussion

Alerts are enabled by default. Enabling alerts when they are already enabled is a no-op.

Declared In

PWAlerts.h

getAlertSegmentsWithSuccess:failure:

Get list of all alert segments and their current subscription status.

+ (void)getAlertSegmentsWithSuccess:(__nullable PWAlertsSegmentSuccess)success failure:(__nullable PWAlertsSegmentFailure)failure

Parameters

success

A block object to be executed when getAlertSegmentsWithSuccess:failure: succeeds. This block has no return value and takes one argument: the alert segments received from the server (an NSArray object that contains the alert segments as PWAlertSegment objects).

failure

A block object to be executed when getAlertSegmentsWithSuccess:failure: fails.This block has no return value and takes one argument: an NSError object describing the error that occurred.

Discussion

This method replaces the deprecated method getSubscriptionGroupsWithSuccess:failure:.

Declared In

PWAlerts.h

getExtraInformationForAlert:success:failure:

Get extra push information associated for the specified alert.

+ (void)getExtraInformationForAlert:(PWAlert *__nonnull)alert success:(void ( ^ __nullable ) ( NSDictionary *__nonnull extraInformation ))success failure:(void ( ^ __nullable ) ( NSError *__nonnull error ))failure

Parameters

alert

The alert for which extra information is requested.

success

A block object to be executed when getExtraInformationForAlert:success:failure: succeeds. This block has no return value and takes one argument: the extra information received from the server. The return object will always be an NSDictionary.

failure

A block object to be executed when getExtraInformationForAlert:success:failure: fails. This block has no return value and takes one argument: an NSError object describing the error that occurred.

Declared In

PWAlerts.h

isOptIn

Checks push opt-in status.

+ (BOOL)isOptIn

Declared In

PWAlerts.h

serviceName

Returns ‘MaaSAlerts’.

+ (NSString *__nonnull)serviceName

Declared In

PWAlerts.h

setDevelopmentModeEnabled:

Optionally called inside application:didFinishLaunchingWithOptions:. By default, your application will use Apple’s production push notification servers. If you would like to use the sandbox push notificiation servers, call [PWAlerts setDevelopmentModeEnabled:YES]. Note that even if development mode is enabled, push notifications will not work in the simulator.

+ (void)setDevelopmentModeEnabled:(BOOL)enabled

Parameters

enabled

A Boolean variable that indicates whether push development mode is enabled.

Declared In

PWAlerts.h

updateAlertSegments:success:failure:

Update the alert segment subscriptions.

+ (void)updateAlertSegments:(NSArray *__nonnull)segments success:(void ( ^ __nullable ) ( ))success failure:(__nullable PWAlertsSegmentFailure)failure

Parameters

segments

An array of one or more PWAlertSegment objects that represent the alert subscriptions.

success

A block object to be executed when updateAlertSegments:success:failure succeeds. This block has no return value and takes no arguments.

failure

A block object to be executed when updateAlertSegments:success:failure: fails. This block has no return value and takes one argument: an NSError object describing the error that occurred.

Discussion

This method replaces the deprecated method subscribeToGroupsWithIDs:success:failure:. It’s very important that you always pass back all known PWAlertSegment objects as this method will subscribe to all PWAlertSegments objects marked for subscription and unsubscribe from all other segments.

Declared In

PWAlerts.h