PWMessaging Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | PWMessaging.h |
Overview
The Location Messaging framework is a location and notification based system.
The recommended way to start Location Messaging in your application is to place a call
to +startWithmaasAppId:accessKey:signatureKey:encryptionKey:completion: in your -application:didFinishLaunchingWithOptions: method.
This delay defaults to 1 second in order to generally give the application time to fully finish launching.
The framework needs you to forward the following methods from your application delegate:
- ‘didFinishLaunchingWithOptions:withCompletionHandler:’
- ‘didRegisterForRemoteNotificationsWithDeviceToken:withNotificationHandler:’
- ‘didFailToRegisterForRemoteNotificationsWithError:withNotificationHandler:’
- ‘didReceiveRemoteNotification:withNotificationHandler:’
You can optionally add a delegate to be informed about errors while initalizing the location marketing service and to control the display of local notifications to the user.
+ startWithMaasAppId:accessKey:signatureKey:encryptionKey:completion:
Starts the Location Messaging service with environment.
+ (void)startWithMaasAppId:(NSString *)maasAppId accessKey:(NSString *)accessKey signatureKey:(NSString *)signatureKey encryptionKey:(NSString *)encryptionKey completion:(void ( ^ ) ( NSError *error ))completionParameters
maasAppId |
You can find your Application ID in the MaaS portal. |
|---|---|
accessKey |
A unique key that identifies the client making the request. You can find your Access Key in the MaaS portal. |
signatureKey |
A unique key that is used to sign requests. The signature is used to both check request authorization as well as data integrity. You can find your Signature Key in the MaaS portal. |
encryptionKey |
The key used to encrypt and decrypt data that is exchanged between the client and the server. You can find your Encryption Key in the MaaS portal. |
completion |
A block that notify location messaging service is successfully started or failed to start with reason. - param1 error It’s nil when it’s started successfully, or an error object containing information about a problem that indicates location messaging service failed to start. |
Return Value
A singleton class of LocationMessaging
Declared In
PWMessaging.h
+ stopWithCompletion:
Stop location messaging service.
+ (void)stopWithCompletion:(void ( ^ ) ( NSError *error ))completionParameters
completion |
A block that notify location messaging service is successfully stopped or failed to stop with reason.
|
|---|
Declared In
PWMessaging.h
+ deviceId
Return the device identifier which the location messaging service uses.
+ (NSString *)deviceIdDeclared In
PWMessaging.h
+ version
Return the current SDK version of location messaging.
+ (NSString *)versionDeclared In
PWMessaging.h
+ serviceName
The name of the location messaging service.
+ (NSString *)serviceNameDeclared In
PWMessaging.h
+ setErrorHandler:
Set the block to handle the error when it occurs.
+ (void)setErrorHandler:(void ( ^ ) ( NSError *error ))handlerParameters
handler |
A block that caused location messaging service failed.
|
|---|
Declared In
PWMessaging.h
+ setLocalNotificationHandler:
Set the block to handle the local notification which is about to display.
+ (void)setLocalNotificationHandler:(BOOL ( ^ ) ( PWMSGLocalNotification *notification ))handlerParameters
handler |
A block that notifies the local notification is about to display, you can control the local notification display and customize the display content.
|
|---|
Discussion
The local notification will be displayed if the block returns YES, otherwise, it will not be displayed.
Declared In
PWMessaging.h
+ didFinishLaunchingWithOptions:withCompletionHandler:
Lets the location messaging service know that launch process is almost done and the app is almost ready to run.(APNs).
+ (void)didFinishLaunchingWithOptions:(NSDictionary *)launchOptions withCompletionHandler:(BOOL ( ^ ) ( PWMSGLocalNotification *notification ))completionHandlerParameters
launchOptions |
A dictionary indicating the reason the app was launched (if any). The contents of this dictionary may be empty in situations where the user launched the app directly. For information about the possible keys in this dictionary and how to handle them, see Launch Options Keys. |
|---|---|
completionHandler |
A block that tells if user opens the app by tapping a notification.
|
Discussion
The message deep linking could be fired from the completionHandler block. And if returns YES in the block, it will prompt an alert tells user how to enable push notification setting when it’s disabled, and the prompted message could be configured in localized string file with key RemindOfEnablePushNotificationSettings.
Declared In
PWMessaging.h
+ didRegisterForRemoteNotificationsWithDeviceToken:
Lets the location messaging service know that the app successfully registered with Apple Push Notification service (APNs).
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceTokenParameters
deviceToken |
A token that identifies the device to APNs. The token is an opaque data type because that is the form that the provider needs to submit to the APNs servers when it sends a notification to a device. The APNs servers require a binary format for performance reasons. The size of a device token is 32 bytes. Note that the device token is different from the uniqueIdentifier property of UIDevice because, for security and privacy reasons, it must change when the device is wiped. |
|---|
Declared In
PWMessaging.h
+ didFailToRegisterForRemoteNotificationsWithError:
Lets the location messaging service know that the Apple Push Notification service cannot successfully complete the registration process.
+ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)errorParameters
error |
An NSError object that encapsulates information why registration did not succeed. The app can choose to display this information to the user. |
|---|
Declared In
PWMessaging.h
+ didReceiveLocalNotification:withNotificationHandler:
Lets the location messaging service know that the app receives a local notification, so that it can process it internally.
+ (void)didReceiveLocalNotification:(UILocalNotification *)notification withNotificationHandler:(void ( ^ ) ( PWMSGLocalNotification *notification ))notificationHandlerParameters
notification |
A |
|---|---|
notificationHandler |
A block that tells the notification with message which was received.
|
Discussion
The message deep linking could be fired from the completion block.
Declared In
PWMessaging.h
+ didReceiveRemoteNotification:withNotificationHandler:
Lets the location messaging service know that the app receives a remote notification, so that it can process it internally.
+ (void)didReceiveRemoteNotification:(NSDictionary *)userInfo withNotificationHandler:(void ( ^ ) ( PWMSGLocalNotification *notification ))notificationHandlerParameters
userInfo |
A dictionary that contains information related to the remote notification, potentially including a badge number for the app icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iOS converts to an NSDictionary object; the dictionary may contain only property-list objects plus NSNull. |
|---|---|
notificationHandler |
A block that tells the notification with message which was received.
|
Discussion
The message deep linking could be fired from the notificationHandler block.
Declared In
PWMessaging.h
+ didReceiveRemoteNotification:fetchCompletionHandler:withNotificationHandler:
Lets the location messaging service know that the app receives a remote notification, so that it can process it internally.
+ (void)didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void ( ^ ) ( UIBackgroundFetchResult ))completionHandler withNotificationHandler:(void ( ^ ) ( PWMSGLocalNotification *notification ))notificationHandlerParameters
userInfo |
A dictionary that contains information related to the remote notification, potentially including a badge number for the app icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iOS converts to an NSDictionary object; the dictionary may contain only property-list objects plus NSNull. |
|---|---|
completionHandler |
The block to execute when the download operation is complete. When calling this block, pass in the fetch result value that best describes the results of your download operation. You must call this handler and should do so as soon as possible. For a list of possible values, see the UIBackgroundFetchResult type.
|
notificationHandler |
A block that tells the notification with message which was received.
|
Discussion
The message deep linking could be fired from the notificationHandler block.
Declared In
PWMessaging.h