-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathLBInstallation.h
109 lines (90 loc) · 2.92 KB
/
LBInstallation.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* @file LBInstallation.h
*
* @author Raymond Feng
* @copyright (c) 2013 StrongLoop. All rights reserved.
*/
#import "LBPersistedModel.h"
#import "LBRESTAdapter.h"
@class LBInstallation;
@class LBInstallationRepository;
/**
* LBInstallation represents the installation of a given app on the device. It
* connects the device token with application/user/timeZone/subscriptions for
* the server to find devices of interest for push notifications.
*/
@interface LBInstallation : LBPersistedModel
/**
* The app id received from LoopBack application signup.
* It's usaully configurd in the Settings.plist file
*/
@property (nonatomic, copy) NSString *appId;
/**
* The application version, default to @"1.0.0"
*/
@property (nonatomic, copy) NSString *appVersion;
/**
* The id for the signed in user for the installation
*/
@property (nonatomic, copy) NSString *userId;
/**
* It's always @"ios"
*/
@property (nonatomic, readonly, copy) NSString *deviceType;
/**
* The device token in hex string format
*/
@property (nonatomic, copy) NSString *deviceToken;
/**
* The current badge
*/
@property (nonatomic, copy) NSNumber *badge;
/**
* An array of topic names that the device subscribes to
*/
@property (nonatomic, copy) NSArray *subscriptions;
/**
* The time zone for the server side to decide a good time for push
*/
@property (nonatomic, readonly, copy) NSString *timeZone;
/**
* Status of the installation
*/
@property (nonatomic, copy) NSString *status;
/**
* Convert the device token from NSData to NSString
*
* @param token The device token in NSData type
* @return The device token in NSString type
*/
+ (NSString *)deviceTokenWithData: (NSData *) token;
/**
* Register the device against LoopBack server
* @param adapter The REST adapter
* @param deviceToken The device token
* @param registrationId The registration id
* @param appId The application id
* @param appVersion The application version
* @param userId The user id
* @param badge The badge
* @param subscriptions An array of string values representing subscriptions to push events
* @param success The success callback block for device registration
* @param failure The failure callback block for device registration
*/
+ (void)registerDeviceWithAdapter: (LBRESTAdapter *) adapter
deviceToken: (NSData *) deviceToken
registrationId: (id) registrationId
appId: (NSString *) appId
appVersion: (NSString *) appVersion
userId: (NSString *) userId
badge: (NSNumber *) badge
subscriptions: (NSArray *) subscriptions
success: (SLSuccessBlock) success
failure: (SLFailureBlock) failure;
@end
/**
* Custom ModelRepository subclass for LBInstallation
*/
@interface LBInstallationRepository : LBPersistedModelRepository
+ (instancetype)repository;
@end