-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathLBPushNotification.h
93 lines (78 loc) · 2.68 KB
/
LBPushNotification.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @file LBPushNotification.h
*
* @author Raymond Feng
* @copyright (c) 2013 StrongLoop. All rights reserved.
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "LBRESTAdapter.h"
/**
@abstract Push Notification Type: Indicates in what state was app when received it (Foreground, Background, Terminated)
@discussion
*/
typedef enum LBPushNotificationType {
/** App was on Foreground */
Foreground = 1,
/** App was on Background */
Background = 2,
/** App was terminated and launched again through Push notification */
Terminated = 3
} LBPushNotificationType;
/**
* Wrapper class to handle received push notifications
* @experimental(Provide helper methods for iOS clients to handle push notifications)
*/
@interface LBPushNotification : NSObject
/**
* The notification type
*/
@property (nonatomic) LBPushNotificationType type;
/**
* The notification payload
*/
@property (nonatomic) NSDictionary *userInfo;
/**
* This method should be called within UIApplicationDelegate's application method.
* - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
* @param application The application
* @param launchOptions The launch options from the application hook
* @return The offline notification
*/
+ (LBPushNotification *) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
/**
* Handle received notification
* @param application The application instance
* @param userInfo The payload
* @return The received notification
*/
+ (LBPushNotification *) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;
/**
* Handle the device token
* @param application The application instance
* @param deviceToken The device token
* @param adapter The REST adapter
* @param userId The user id
* @param subscriptions The list of subscribed topics
* @param success The success callback block
* @param failure The failure callback block
*/
+ (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
adapter:(LBRESTAdapter *)adapter userId:(NSString *)userId subscriptions:(NSArray *)subscriptions
success:(SLSuccessBlock)success failure:(SLFailureBlock)failure;
/**
* Handle failure to receive device token
*/
+ (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error;
/**
* Reset badge
* @param badge The new badge value
* @return The old badge
*/
+ (NSInteger) resetBadge:(NSInteger)badge;
/**
* Get the current badge value
* @return The badge value
*/
+ (NSInteger) getBadge;
@end