@protocolAPNSHandlerDelegate <NSObject>
@optional/** * Will be called only once in an app install * * @param canDisplayNotification If YES: user already tap on either Don't Allow or Allow button. If NO: user never sees the system Alert View before, it's a good time to display your own custom UI first then call registerNotificationSettings * @param didPrompt If YES: user never see the prompt from system before. If NO: user used to make a decision, so no UI was displayed. Good time to display a custom popup to guide user to enable in SETTINGS > NOTIFICATIONS > Your_App_name > ENABLED > TURN ON! * @param types UIUserNotificationType*/
- (void)APNSHandler:(APNSHandler*)handlerdidAskForNotificationSettingsWithPrompt:(BOOL)didPromptcanDisplayNotification:(BOOL)canDisplayNotification;
/** * Received device token from Apple * * @param deviceToken NSString*/
- (void)APNSHandler:(APNSHandler*)handlerdidRegisterForRemoteNotificationsWithDeviceToken:(NSString*)deviceToken;
/** * Probably changed manually by user. Called when app becomes active if there's any change. * * @param notificationTypes UIUserNotificationType*/
- (void)APNSHandler:(APNSHandler*)handlernotificationSettingsUpdated:(UIUserNotificationSettings*)notificationSettingscanDisplayNotification:(BOOL)canDisplayNotification;
/** * Fail to register remote notification because of internet connectivity or denial * * @param error NSError*/
- (void)APNSHandler:(APNSHandler*)handlerdidFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
@end/** * APNSHandler is only iOS 8 compatible.*/@interfaceAPNSHandler : NSObject
+ (instancetype)sharedInstance;
/** * If YES: it either means you can fire a LOCAL notification; can register REMOTE notification; and can receive and display PUSH notification from server * If NO: UIUserNotificationTypeNone*/@property (nonatomic) BOOL canDisplayNotification;
/** * Return the last deviceToken, can be new or cached since the last app launch*/@property (nonatomic, strong) NSString *deviceToken;
/** * Default: YES. If your app doesn't have Push Notification or you want to control when to call, set this flag to NO.*/@property (nonatomic) BOOL shouldAutoRegisterRemoteNotification;
/** * APNSHandlerDelegate*/@property (nonatomic, weak) id<APNSHandlerDelegate>delegate;
/** * Start listening to significant events*/
- (void)setup;
/** * Call to UIApplication registerUserNotificationSettings but start a timer (as a trick) to measure whether a system alert was shown * * @param notificationSettings UIUserNotificationSettings*/
- (void)registerUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
/** * Call to UIApplication registerForRemoteNotifications*/
- (void)registerForRemoteNotifications;
/** * Call to UIApplication registerForRemoteNotifications if did not register before*/
- (void)registerForRemoteNotificationsIfNecessary;
/** * Handler. Please put in didRegisterUserNotificationSettings * * @param application UIApplication * @param notificationSettings UIUserNotificationSettings*/
- (void)handleApplication:(UIApplication *)applicationdidRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
/** * Handler. Please put in didRegisterForRemoteNotificationsWithDeviceToken * * @param application UIApplication * @param deviceToken NSData*/
- (void)handleApplication:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
/** * Handler. Please put in didFailToRegisterForRemoteNotificationsWithError * * @param application UIApplication * @param error NSError*/
- (void)handleApplication:(UIApplication *)applicationdidFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
@end