9
9
#import < Foundation/Foundation.h>
10
10
#import < UIKit/UIKit.h>
11
11
#import < Intercom/ICMUserAttributes.h>
12
+ #import < Intercom/ICMUserAttributesValidation.h>
13
+ #import < Intercom/ICMCompany.h>
12
14
#import < Intercom/ICMHelpCenterCollection.h>
13
15
#import < Intercom/ICMHelpCenterSection.h>
14
16
#import < Intercom/ICMHelpCenterArticle.h>
84
86
85
87
NS_ASSUME_NONNULL_BEGIN
86
88
87
- /* *
88
- Intercom is your direct line of communication to every user, right inside your app. Intercom’s in-app messages
89
- are up to 10 times more effective than email too! Send the right messages, to the right users, at exactly the right time.
90
-
91
- ## How do I track my users?
92
-
93
- In order to see your users in Intercom's user list, you must first register them via your iOS application. If you have a
94
- place in your application where you become aware of the user's identity such as a log in view controller, call one of the
95
- following depending on the information you have available for that user:
96
-
97
- If you have both a unique user identifier and an email for your users::
98
-
99
- [Intercom registerUserWithUserId:@"123456" email:@"[email protected] "];
100
-
101
- If you only have a unique identifier for your users:
102
-
103
- [Intercom registerUserWithUserId:@"123456"];
104
-
105
- Finally, if you only have an email address for your users:
106
-
107
- [Intercom registerUserWithEmail:@"[email protected] "];
108
-
109
- ## Can I track unidentified users?
110
-
111
- Yes, absolutely. If you have an application that doesn't require users to log in, you can call:
112
-
113
- [Intercom registerUnidentifiedUser];
114
-
115
- If the user subsequently logs in or you learn additional information about them (e.g. get an email address),
116
- calling any of the other user registration methods will update that user's identity in Intercom and contain
117
- all user data tracked previously.
118
-
119
- ## How do push notifications work?
120
-
121
- Intercom for iOS enables your users to receive push notifications for new messages. Simply call:
122
-
123
- - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
124
- [Intercom setDeviceToken:deviceToken];
125
- }
126
-
127
- in your `didRegisterForRemoteNotificationsWithDeviceToken:` method once you have registered your app for
128
- push notifications with the `UIApplicationDelegate`.
129
-
130
- When your app receives a push notification Intercom for iOS checks to see if it is an Intercom push notification
131
- and opens the message. You do not need to implement any additional code in order to launch the message window.
132
-
133
- To do this we [safely swizzle](http://blog.newrelic.com/2014/04/16/right-way-to-swizzle/) the public methods
134
- in `UIApplicationDelegate` that handle receiving push notifications. We do not use any private APIs to do this.
135
-
136
- ## More information
137
-
138
- Full documentation is available [here](https://developers.intercom.com/docs/ios-installation ) and please contact
139
- us directly via Intercom for any support or questions you may have.
140
-
141
- */
142
89
@interface Intercom : NSObject
143
90
144
91
#pragma mark - Intercom Initialisation
@@ -165,70 +112,94 @@ NS_ASSUME_NONNULL_BEGIN
165
112
and which can store a secret. More information on Identity Verification can be found [here](https://developers.intercom.com/docs/ios-identity-verification)
166
113
167
114
168
- @note This should be called before any user registration takes place.
115
+ @note This should be called before any user login takes place.
169
116
@param userHash A HMAC digest of the user ID or email.
170
117
*/
171
118
+ (void )setUserHash : (NSString *)userHash ;
172
119
173
- #pragma mark - User Registration
120
+ #pragma mark - User Login
174
121
175
122
// =========================================================================================================
176
123
/* ! @name Working with anonymous users */
177
124
// =========================================================================================================
125
+ /* !
126
+ If you call loginUnidentifiedUserWithSuccess:failure:, all activity will be tracked anonymously. If you choose to
127
+ subsequently identify that user, all that anonymous activity will be merged into the identified user. This means that
128
+ you will no longer see the anonymous user in Intercom, but rather the identified one.
129
+
130
+ We recommend this is called from within the application delegate's didFinishLaunchingWithOptions: method.
131
+ @param success A nullable success callback with no parameters.
132
+ @param failure A failure callback with an error parameter.
133
+ @note You must call one of the user login methods in order to start communicating with Intercom.
134
+ */
135
+ + (void )loginUnidentifiedUserWithSuccess : (void (^ __nullable)(void ))success failure : (void (^ __nullable)(NSError *_Nonnull error))failure NS_REFINED_FOR_SWIFT;
136
+
178
137
/* !
179
138
If you call registerUnidentifiedUser, all activity will be tracked anonymously. If you choose to subsequently
180
139
identify that user, all that anonymous activity will be merged into the identified user. This means that you
181
140
will no longer see the anonymous user in Intercom, but rather the identified one.
182
141
183
142
We recommend this is called from within the application delegate's didFinishLaunchingWithOptions: method.
184
143
185
- @note You must call one of the user registration methods in order to start communicating with Intercom.
144
+ @note You must call one of the user login methods in order to start communicating with Intercom.
186
145
*/
187
- + (void )registerUnidentifiedUser ;
146
+ + (void )registerUnidentifiedUser __attribute((deprecated( " '+[Intercom registerUnidentifiedUser]' is deprecated. 'Use +[Intercom loginUnidentifiedUserWithSuccess:failure:]' instead. " ))) ;
188
147
189
148
// =========================================================================================================
190
149
/* ! @name Working with identified users */
191
150
// =========================================================================================================
192
151
/* !
193
- In order to keep track of a specific user, you must identify it with a unique user identifier, an email
194
- address, or both. By supplying information like this Intercom provides richer user profiles for your users.
195
- This is a userId, supplied by you (e.g. from an existing web service for your product) to represent your
196
- user in Intercom, once set it cannot be changed.
152
+ In order to keep track of a specific user, you must identify it with a unique user identity, an email
153
+ address, or both. To provide these, you must first create a new `ICMUserAttributes` object and then populate
154
+ the `email` and/or `userId` properties for that object. This is a userId, supplied by you (e.g. from an
155
+ existing web service for your product) to represent your user in Intercom, once set it cannot be changed.
156
+
157
+ As well as the `email` and `userId` fields, you can populate the other user attribute fields within
158
+ `ICMUserAttributes` when you login as an identified user. By supplying information like this, Intercom
159
+ provides richer user profiles for your users.
197
160
198
161
If you are putting Intercom for iOS into an app that has persisted an authentication token or equivalent
199
- so your users don't have to log in repeatedly (like most apps) then we advise putting the user registration
162
+ so your users don't have to log in repeatedly (like most apps) then we advise putting the user login
200
163
call in the `didBecomeActive:` method in your application delegate. This won't have any negative impact if
201
164
you also add it to your authentication success method elsewhere in your app.
202
165
203
- @param userId A unique identifier for your user .
204
- @param email Your user's email address .
205
- @note You must call one of the user registration methods in order to start communicating with Intercom .
166
+ @param userAttributes An `ICMUserAttributes` object. Either or both `email` and `userId` properties must be populated .
167
+ @param success A nullable success callback with no parameters .
168
+ @param failure A failure callback with an error parameter .
206
169
*/
207
- + (void )registerUserWithUserId : ( NSString *)userId email : ( NSString *) email ;
170
+ + (void )loginUserWithUserAttributes : (ICMUserAttributes *)userAttributes success : ( void (^ __nullable)( void )) success failure : ( void (^ __nullable)( NSError *_Nonnull error)) failure NS_REFINED_FOR_SWIFT ;
208
171
209
172
/* !
210
- Register a user just with their userId.
173
+ Login as a user just with their userId and email.
174
+
175
+ @param userId A unique identifier for your user.
176
+ @param email Your user's email address.
177
+ @note You must call one of the user registration methods in order to start communicating with Intercom.
178
+ */
179
+ + (void )registerUserWithUserId : (NSString *)userId email : (NSString *)email __attribute((deprecated(" '+[Intercom registerUserWithUserId:email:]' is deprecated. 'Use +[Intercom loginUserWithUserAttributes:success:failure:]' instead." )));
211
180
181
+ /* !
182
+ Login as a user just with their userId.
212
183
@param userId A unique identifier for your user.
213
184
@note You must call one of the user registration methods in order to start communicating with Intercom.
214
185
*/
215
- + (void )registerUserWithUserId : (NSString *)userId ;
186
+ + (void )registerUserWithUserId : (NSString *)userId __attribute((deprecated( " '+[Intercom registerUserWithUserId:]' is deprecated. 'Use +[Intercom loginUserWithUserAttributes:success:failure:]' instead. " ))) ;
216
187
217
188
/* !
218
- Register a user with just their email address.
189
+ Login as a user with just their email address.
219
190
220
191
@param email Your user's email address.
221
192
@note You must call one of the user registration methods in order to start communicating with Intercom.
222
193
*/
223
- + (void )registerUserWithEmail : (NSString *)email ;
194
+ + (void )registerUserWithEmail : (NSString *)email __attribute((deprecated( " '+[Intercom registerUserWithEmail:]' is deprecated. 'Use +[Intercom loginUserWithUserAttributes:success:failure:]' instead. " ))) ;
224
195
225
196
// =========================================================================================================
226
197
/* ! @name Logging the user out */
227
198
// =========================================================================================================
228
199
/* !
229
200
logout is used to clear all local caches and user data Intercom has created. Logout will also close any active
230
201
UI that is on screen. Use this at a time when you wish to log a user out of your app or change a user.
231
- Once called, Intercom for iOS will no longer communicate with Intercom until a further registration is made.
202
+ Once called, Intercom for iOS will no longer communicate with Intercom until a further login is made.
232
203
*/
233
204
+ (void )logout ;
234
205
@@ -240,6 +211,19 @@ NS_ASSUME_NONNULL_BEGIN
240
211
// =========================================================================================================
241
212
/* * @name Updating the user */
242
213
// =========================================================================================================
214
+ /* !
215
+ You can send any data you like to Intercom. Typically our customers see a lot of value in sending data that
216
+ relates to customer development, such as price plan, value of purchases, etc. Once these have been sent to
217
+ Intercom you can then apply filters based on these attributes.
218
+
219
+ Details on attributes available to update can be found in ICMUserAttributes.
220
+
221
+ @param userAttributes The attributes to update the user with.
222
+ @param success A nullable success callback with no parameters.
223
+ @param failure A failure callback with an error parameter.
224
+ */
225
+ + (void )updateUser : (ICMUserAttributes *)userAttributes success : (void (^ __nullable)(void ))success failure : (void (^ __nullable)(NSError *_Nonnull error))failure NS_REFINED_FOR_SWIFT;
226
+
243
227
/* !
244
228
You can send any data you like to Intercom. Typically our customers see a lot of value in sending data that
245
229
relates to customer development, such as price plan, value of purchases, etc. Once these have been sent to
@@ -249,7 +233,7 @@ NS_ASSUME_NONNULL_BEGIN
249
233
250
234
@param userAttributes The attributes to update the user with.
251
235
*/
252
- + (void )updateUser : (ICMUserAttributes *)userAttributes ;
236
+ + (void )updateUser : (ICMUserAttributes *)userAttributes __attribute((deprecated( " '+[Intercom updateUser:]' is deprecated. 'Use +[Intercom updateUser:success:failure:]' instead. " ))) ;
253
237
254
238
#pragma mark - Log Event
255
239
@@ -373,14 +357,23 @@ NS_ASSUME_NONNULL_BEGIN
373
357
// =========================================================================================================
374
358
/* ! @name Working with push notifications */
375
359
// =========================================================================================================
360
+ /* !
361
+ Set the device token for push notifications. Once the device token is set, the methods for receiving push
362
+ notifications are safely swizzled so ones sent from Intercom can be intercepted. When a push notification from
363
+ Intercom is received, Intercom for iOS will automatically launch the message from the notification.
364
+ @param deviceToken The device token provided in the `didRegisterForRemoteNotificationsWithDeviceToken` method.
365
+ @param failure A failure callback with an error parameter.
366
+ */
367
+ + (void )setDeviceToken : (NSData *)deviceToken failure : (void (^ __nullable)(NSError * _Nullable error))failure ;
368
+
376
369
/* !
377
370
Set the device token for push notifications. Once the device token is set, the methods for receiving push
378
371
notifications are safely swizzled so ones sent from Intercom can be intercepted. When a push notification from
379
372
Intercom is received, Intercom for iOS will automatically launch the message from the notification.
380
373
381
374
@param deviceToken The device token provided in the `didRegisterForRemoteNotificationsWithDeviceToken` method.
382
375
*/
383
- + (void )setDeviceToken : (NSData *)deviceToken ;
376
+ + (void )setDeviceToken : (NSData *)deviceToken __attribute((deprecated( " '+[Intercom setDeviceToken:]' is deprecated. 'Use +[Intercom setDeviceToken:failure:]' instead. " ))) ;
384
377
385
378
/* !
386
379
Use this method to check if a push notification payload was sent by Intercom. Typically you should call
0 commit comments