AWSPinpointNotificationManager

Objective-C

@interface AWSPinpointNotificationManager : NSObject

typedef NS_ENUM(NSInteger, AWSPinpointPushActionType) {
    AWSPinpointPushActionTypeOpened,
    AWSPinpointPushActionTypeReceivedForeground,
    AWSPinpointPushActionTypeReceivedBackground,
    AWSPinpointPushActionTypeUnknown
};

typedef NS_ENUM(NSInteger, AWSPinpointPushEventSourceType) {
    AWSPinpointPushEventSourceTypeCampaign,
    AWSPinpointPushEventSourceTypeJourney,
    AWSPinpointPushEventSourceTypeUnknown
};

typedef NS_ENUM(NSInteger, AWSPinpointPushEvent) {
    AWSPinpointPushEventReceived,
    AWSPinpointPushEventOpened
};

#pragma mark - Notification Helpers

///
/// Returns a Boolean indicating whether the app is currently registered for remote notifications.
/// - Warning: Calling this method from a non-main thread might result in a deadlock if the main queue is blocked.
/// - Returns: YES if the app is registered for remote notifications and received its device token or NO if registration has not occurred, has failed, or has been denied by the user.
+ (BOOL)isNotificationEnabled;

#pragma mark - Interceptors
/**
 Invoke this method from the `- application:didFinishLaunchingWithOptions:` application delegate method.
 
 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.
 
 @param 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.
 */
- (BOOL)interceptDidFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions;

/**
 Invoke this method from the `- application:didRegisterForRemoteNotificationsWithDeviceToken:` application delegate
 method.
 
 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.
 
 @param deviceToken A token that identifies the device to APNs.
 */
- (void)interceptDidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;

/**
 Invoke this method from the `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` application delegate
 method.

 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.
 
 @param 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`.
 @param handler     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.
 */
- (void)interceptDidReceiveRemoteNotification:(NSDictionary *)userInfo
                       fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler __attribute__((deprecated("Replaced by -interceptDidReceiveRemoteNotification:")));

/**
 For iOS 9 and below, invoke this method from the `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)`
 application delegate method.

 For iOS 10 and above, invoke this method from the `userNotificationCenter(_:willPresent:withCompletionHandler:)` and
 `userNotificationCenter(_:didReceive:withCompletionHandler:)` UserNotificationCenter methods. When invoking this method
 from `willPresent`, pass in `notification.request.content.userInfo` as userInfo. When invoking this method on
 `didReceive`, pass in `response.notification.request.content.userInfo` as `userInfo`.

 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

 @param 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`.
 */
- (void)interceptDidReceiveRemoteNotification:(NSDictionary *)userInfo;

/**
 For iOS 9 and below, invoke this method from the `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)`
 application delegate method.

 For iOS 10 and above, invoke this method from the `userNotificationCenter(_:willPresent:withCompletionHandler:)` and
 `userNotificationCenter(_:didReceive:withCompletionHandler:)` UserNotificationCenter methods. When invoking this method
 from `willPresent`, pass in `notification.request.content.userInfo` as userInfo. When invoking this method on
 `didReceive`, pass in `response.notification.request.content.userInfo` as `userInfo`.

 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

 @param 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`.
 @param pushEvent  Event for push which is either `received` or `opened`.
 */
- (void)interceptDidReceiveRemoteNotification:(NSDictionary *)userInfo
                                    pushEvent:(AWSPinpointPushEvent)pushEvent;

/**
 Invoke this method from the `application:didReceiveRemoteNotification:fetchCompletionHandler:shouldHandleNotificationDeepLink:`
 application delegate method.

 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly. Optionally
 specify 'shouldHandleNotificationDeepLink' to control whether or not the notification manager should attempt to open
 the remote notification deeplink, if present.

 @param 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`.
 @param handler         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.
 @param handleDeepLink  Whether or not notification manager should attempt to open the remote notification deeplink, if
 present.
 */
- (void)interceptDidReceiveRemoteNotification:(NSDictionary *)userInfo
                       fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
             shouldHandleNotificationDeepLink:(BOOL) handleDeepLink __attribute__((deprecated("Replaced by -interceptDidReceiveRemoteNotification:shouldHandleNotificationDeepLink:")));

/**
 For iOS 9 and below, intercept the `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` application
 delegate.

 For iOS 10 and above, invoke this method from the `userNotificationCenter(_:willPresent:withCompletionHandler:)` and
 `userNotificationCenter(_:didReceive:withCompletionHandler:)` UserNotificationCenter methods. When invoking this method
 from `willPresent`, pass in `notification.request.content.userInfo` as userInfo. When invoking this method on
 `didReceive`, pass in `response.notification.request.content.userInfo` as `userInfo`.

 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly. Optionally
 specify 'shouldHandleNotificationDeepLink' to control whether or not the notification manager should attempt to open
 the remote notification deeplink, if present.

 @param 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`.
 @param handleDeepLink  Whether or not notification manager should attempt to open the remote notification deeplink, if
 present
 */
- (void)interceptDidReceiveRemoteNotification:(NSDictionary *)userInfo
             shouldHandleNotificationDeepLink:(BOOL) handleDeepLink;

/**
 For iOS 9 and below, intercept the `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` application
 delegate.

 For iOS 10 and above, invoke this method from the `userNotificationCenter(_:willPresent:withCompletionHandler:)` and
 `userNotificationCenter(_:didReceive:withCompletionHandler:)` UserNotificationCenter methods. When invoking this method
 from `willPresent`, pass in `notification.request.content.userInfo` as userInfo. When invoking this method on
 `didReceive`, pass in `response.notification.request.content.userInfo` as `userInfo`.

 The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly. Optionally
 specify 'shouldHandleNotificationDeepLink' to control whether or not the notification manager should attempt to open
 the remote notification deeplink, if present.

 @param 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`.
 @param handleDeepLink  Whether or not notification manager should attempt to open the remote notification deeplink, if
 present.
 @param pushEvent  Event for push which is either `received` or `opened`.
 */
- (void)interceptDidReceiveRemoteNotification:(NSDictionary *)userInfo
                                    pushEvent:(AWSPinpointPushEvent)pushEvent
             shouldHandleNotificationDeepLink:(BOOL) handleDeepLink;

@end

Swift

class AWSPinpointNotificationManager : NSObject

Undocumented

Notification Helpers

  • Returns a Boolean indicating whether the app is currently registered for remote notifications.

    Warning

    Calling this method from a non-main thread might result in a deadlock if the main queue is blocked.

    Declaration

    Objective-C

    + (BOOL)isNotificationEnabled;

    Swift

    class func isNotificationEnabled() -> Bool

    Return Value

    YES if the app is registered for remote notifications and received its device token or NO if registration has not occurred, has failed, or has been denied by the user.

Interceptors

  • Invoke this method from the - application:didFinishLaunchingWithOptions: application delegate method.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

    Declaration

    Objective-C

    - (BOOL)interceptDidFinishLaunchingWithOptions:
        (nullable NSDictionary *)launchOptions;

    Swift

    func interceptDidFinishLaunching(options launchOptions: [AnyHashable : Any]? = nil) -> Bool

    Parameters

    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.

  • Invoke this method from the - application:didRegisterForRemoteNotificationsWithDeviceToken: application delegate method.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

    Declaration

    Objective-C

    - (void)interceptDidRegisterForRemoteNotificationsWithDeviceToken:
        (nonnull NSData *)deviceToken;

    Swift

    func interceptDidRegisterForRemoteNotifications(withDeviceToken deviceToken: Data)

    Parameters

    deviceToken

    A token that identifies the device to APNs.

  • Deprecated

    Replaced by -interceptDidReceiveRemoteNotification:

    Invoke this method from the application(_:didReceiveRemoteNotification:fetchCompletionHandler:) application delegate method.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

    Declaration

    Objective-C

    - (void)interceptDidReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                           fetchCompletionHandler:
                               (nonnull void (^)(UIBackgroundFetchResult))handler;

    Swift

    func interceptDidReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], fetchCompletionHandler handler: @escaping (UIBackgroundFetchResult) -> Void)

    Parameters

    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.

    handler

    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.

  • For iOS 9 and below, invoke this method from the application(_:didReceiveRemoteNotification:fetchCompletionHandler:) application delegate method.

    For iOS 10 and above, invoke this method from the userNotificationCenter(_:willPresent:withCompletionHandler:) and userNotificationCenter(_:didReceive:withCompletionHandler:) UserNotificationCenter methods. When invoking this method from willPresent, pass in notification.request.content.userInfo as userInfo. When invoking this method on didReceive, pass in response.notification.request.content.userInfo as userInfo.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

    Declaration

    Objective-C

    - (void)interceptDidReceiveRemoteNotification:(nonnull NSDictionary *)userInfo;

    Swift

    func interceptDidReceiveRemoteNotification(_ userInfo: [AnyHashable : Any])

    Parameters

    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.

  • For iOS 9 and below, invoke this method from the application(_:didReceiveRemoteNotification:fetchCompletionHandler:) application delegate method.

    For iOS 10 and above, invoke this method from the userNotificationCenter(_:willPresent:withCompletionHandler:) and userNotificationCenter(_:didReceive:withCompletionHandler:) UserNotificationCenter methods. When invoking this method from willPresent, pass in notification.request.content.userInfo as userInfo. When invoking this method on didReceive, pass in response.notification.request.content.userInfo as userInfo.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly.

    Declaration

    Objective-C

    - (void)interceptDidReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                                        pushEvent:(AWSPinpointPushEvent)pushEvent;

    Swift

    func interceptDidReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], pushEvent: AWSPinpointPushEvent)

    Parameters

    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.

    pushEvent

    Event for push which is either received or opened.

  • Deprecated

    Replaced by -interceptDidReceiveRemoteNotification:shouldHandleNotificationDeepLink:

    Invoke this method from the application:didReceiveRemoteNotification:fetchCompletionHandler:shouldHandleNotificationDeepLink: application delegate method.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly. Optionally specify ‘shouldHandleNotificationDeepLink’ to control whether or not the notification manager should attempt to open the remote notification deeplink, if present.

    Declaration

    Objective-C

    - (void)interceptDidReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                           fetchCompletionHandler:
                               (nonnull void (^)(UIBackgroundFetchResult))handler
                 shouldHandleNotificationDeepLink:(BOOL)handleDeepLink;

    Swift

    func interceptDidReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], fetchCompletionHandler handler: @escaping (UIBackgroundFetchResult) -> Void, shouldHandleNotificationDeepLink handleDeepLink: Bool)

    Parameters

    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.

    handler

    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.

    handleDeepLink

    Whether or not notification manager should attempt to open the remote notification deeplink, if present.

  • For iOS 9 and below, intercept the application(_:didReceiveRemoteNotification:fetchCompletionHandler:) application delegate.

    For iOS 10 and above, invoke this method from the userNotificationCenter(_:willPresent:withCompletionHandler:) and userNotificationCenter(_:didReceive:withCompletionHandler:) UserNotificationCenter methods. When invoking this method from willPresent, pass in notification.request.content.userInfo as userInfo. When invoking this method on didReceive, pass in response.notification.request.content.userInfo as userInfo.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly. Optionally specify ‘shouldHandleNotificationDeepLink’ to control whether or not the notification manager should attempt to open the remote notification deeplink, if present.

    Declaration

    Objective-C

    - (void)interceptDidReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                 shouldHandleNotificationDeepLink:(BOOL)handleDeepLink;

    Swift

    func interceptDidReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], shouldHandleNotificationDeepLink handleDeepLink: Bool)

    Parameters

    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.

    handleDeepLink

    Whether or not notification manager should attempt to open the remote notification deeplink, if present

  • For iOS 9 and below, intercept the application(_:didReceiveRemoteNotification:fetchCompletionHandler:) application delegate.

    For iOS 10 and above, invoke this method from the userNotificationCenter(_:willPresent:withCompletionHandler:) and userNotificationCenter(_:didReceive:withCompletionHandler:) UserNotificationCenter methods. When invoking this method from willPresent, pass in notification.request.content.userInfo as userInfo. When invoking this method on didReceive, pass in response.notification.request.content.userInfo as userInfo.

    The Pinpoint targeting client must intercept this callback in order to report campaign analytics correctly. Optionally specify ‘shouldHandleNotificationDeepLink’ to control whether or not the notification manager should attempt to open the remote notification deeplink, if present.

    Declaration

    Objective-C

    - (void)interceptDidReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                                        pushEvent:(AWSPinpointPushEvent)pushEvent
                 shouldHandleNotificationDeepLink:(BOOL)handleDeepLink;

    Swift

    func interceptDidReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], pushEvent: AWSPinpointPushEvent, shouldHandleNotificationDeepLink handleDeepLink: Bool)

    Parameters

    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.

    handleDeepLink

    Whether or not notification manager should attempt to open the remote notification deeplink, if present.

    pushEvent

    Event for push which is either received or opened.