1
1
//
2
2
// Intercom.h
3
- // Intercom for iOS - Version 3.0.16
3
+ // Intercom for iOS - Version 3.0.17
4
4
//
5
5
// Created by Intercom on 8/01/2015.
6
6
// Copyright (c) 2014 Intercom. All rights reserved.
10
10
#import < UIKit/UIKit.h>
11
11
12
12
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
13
- #error This version (3.0.16 ) of Intercom for iOS supports iOS 8.0 upwards.
13
+ #error This version (3.0.17 ) of Intercom for iOS supports iOS 8.0 upwards.
14
14
#endif
15
15
16
16
NS_ASSUME_NONNULL_BEGIN
@@ -25,57 +25,57 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
25
25
/* *
26
26
Intercom is your direct line of communication to every user, right inside your app. Intercom’s in-app messages
27
27
are up to 10 times more effective than email too! Send the right messages, to the right users, at exactly the right time.
28
-
28
+
29
29
## How do I track my users?
30
-
30
+
31
31
In order to see your users in Intercom's user list, you must first register them via your iOS application. If you have a
32
32
place in your application where you become aware of the user's identity such as a log in view controller, call one of the
33
33
following depending on the information you have available for that user:
34
-
34
+
35
35
If you have both a unique user identifier and an email for your users::
36
-
36
+
37
37
[Intercom registerUserWithUserId:@"123456" email:@"[email protected] "];
38
-
38
+
39
39
If you only have a unique identifier for your users:
40
-
40
+
41
41
[Intercom registerUserWithUserId:@"123456"];
42
-
42
+
43
43
Finally, if you only have an email address for your users:
44
-
44
+
45
45
[Intercom registerUserWithEmail:@"[email protected] "];
46
-
46
+
47
47
## Can I track unidentified users?
48
-
48
+
49
49
Yes, absolutely. If you have an application that doesn't require users to log in, you can call:
50
-
50
+
51
51
[Intercom registerUnidentifiedUser];
52
-
52
+
53
53
If the user subsequently logs in or you learn additional information about them (e.g. get an email address),
54
54
calling any of the other user registration methods will update that user's identity in Intercom and contain
55
55
all user data tracked previously.
56
56
57
57
## How do push notifications work?
58
-
58
+
59
59
Intercom for iOS enables your users to receive push notifications for new messages. Simply call:
60
-
60
+
61
61
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
62
62
[Intercom setDeviceToken:deviceToken];
63
63
}
64
-
64
+
65
65
in your `didRegisterForRemoteNotificationsWithDeviceToken:` method once you have registered your app for
66
66
push notifications with the `UIApplicationDelegate`.
67
-
67
+
68
68
When your app receives a push notification Intercom for iOS checks to see if it is an Intercom push notification
69
69
and opens the message. You do not need to implement any additional code in order to launch the message window.
70
-
70
+
71
71
To do this we [safely swizzle](http://blog.newrelic.com/2014/04/16/right-way-to-swizzle/) the public methods
72
72
in `UIApplicationDelegate` that handle receiving push notifications. We do not use any private APIs to do this.
73
-
73
+
74
74
## More information
75
-
75
+
76
76
Full documentation is available [here](https://docs.intercom.io/install-on-your-product-or-site/quick-install/install-intercom-on-your-ios-app) and please contact
77
77
us directly via Intercom for any support or questions you may have.
78
-
78
+
79
79
*/
80
80
@interface Intercom : NSObject
81
81
@@ -85,7 +85,7 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
85
85
/* !
86
86
Initialize Intercom with your iOS API key and App ID. This will allow your app to connect with Intercom.
87
87
This is best done in the application delegate's didFinishLaunchingWithOptions: method.
88
-
88
+
89
89
@param apiKey The iOS API key found on the API Key settings page.
90
90
@param appId The App ID of your Intercom app.
91
91
*/
@@ -99,7 +99,7 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
99
99
user can't impersonate another. In Secure Mode Intercom for iOS will sign all requests going to the Intercom servers
100
100
with tokens. It requires your mobile application to have its own server which authenticates the app's users,
101
101
and which can store a secret. More information on secure mode can be found [here](http://docs.intercom.io/Install-on-your-mobile-product/enabling-secure-mode-in-intercom-for-ios)
102
-
102
+
103
103
@note This should be called before any user registration takes place.
104
104
@param hmac A HMAC digest of data.
105
105
@param data A piece of user data.
@@ -113,9 +113,9 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
113
113
If you call registerUnidentifiedUser, all activity will be tracked anonymously. If you choose to subsequently
114
114
identify that user, all that anonymous activity will be merged into the identified user. This means that you
115
115
will no longer see the anonymous user in Intercom, but rather the identified one.
116
-
116
+
117
117
We recommend this is called from within the application delegate's didFinishLaunchingWithOptions: method.
118
-
118
+
119
119
@note You must call one of the user registration methods in order to start communicating with Intercom.
120
120
*/
121
121
+ (void )registerUnidentifiedUser ;
@@ -128,12 +128,12 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
128
128
address, or both. By supplying information like this Intercom provides richer user profiles for your users.
129
129
This is a userId, supplied by you (e.g. from an existing web service for your product) to represent your
130
130
user in Intercom, once set it cannot be changed.
131
-
131
+
132
132
If you are putting Intercom for iOS into an app that has persisted an authentication token or equivalent
133
133
so your users don't have to log in repeatedly (like most apps) then we advise putting the user registration
134
134
call in the `didBecomeActive:` method in your application delegate. This won't have any negative impact if
135
135
you also add it to your authentication success method elsewhere in your app.
136
-
136
+
137
137
@param userId A unique identifier for your user.
138
138
@param email Your user's email address.
139
139
@note You must call one of the user registration methods in order to start communicating with Intercom.
@@ -142,15 +142,15 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
142
142
143
143
/* !
144
144
Register a user just with their userId.
145
-
145
+
146
146
@param userId A unique identifier for your user.
147
147
@note You must call one of the user registration methods in order to start communicating with Intercom.
148
148
*/
149
149
+ (void )registerUserWithUserId : (NSString *)userId ;
150
150
151
151
/* !
152
152
Register a user with just their email address.
153
-
153
+
154
154
@param email Your user's email address.
155
155
@note You must call one of the user registration methods in order to start communicating with Intercom.
156
156
*/
@@ -160,7 +160,7 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
160
160
/* ! @name Resetting user data */
161
161
// =========================================================================================================
162
162
/* !
163
- reset is used to reset all local caches and user data Intercom has created. Reset will also close any active
163
+ reset is used to reset all local caches and user data Intercom has created. Reset will also close any active
164
164
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.
165
165
Once called, Intercom for iOS will no longer communicate with Intercom until a further registration is made.
166
166
*/
@@ -173,69 +173,69 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
173
173
You can send any data you like to Intercom. Typically our customers see a lot of value in sending data that
174
174
relates to customer development, such as price plan, value of purchases, etc. Once these have been sent to
175
175
Intercom you can then apply filters based on these attributes.
176
-
176
+
177
177
A detailed list of the fields you can use to [update a user is available here](https://developers.intercom.io/reference/#user-model )
178
-
178
+
179
179
Attributes such as the user email or name can be updated by calling
180
-
180
+
181
181
[Intercom updateUserWithAttributes:@{
182
182
183
183
@"name" : @"Admin Name"
184
184
}];
185
-
185
+
186
186
Custom user attributes can be created and modified by passing a custom_attributes dictionary
187
187
You do not have to create attributes in Intercom beforehand. If one hasn't been seen before, it will be
188
188
created for you automatically.
189
-
189
+
190
190
[Intercom updateUserWithAttributes:@{
191
191
@"custom_attributes": @{
192
192
@"paid_subscriber" : @YES,
193
193
@"monthly_spend": @155.5,
194
194
@"team_mates": @3
195
195
}
196
196
}];
197
-
197
+
198
198
You can also set company data via this call by submitting an attribute dictionary like
199
-
199
+
200
200
[Intercom updateUserWithAttributes:@{
201
201
@"companies": @[ @{
202
202
@"name" : @"My Company",
203
203
@"id" : @"abcd1234"
204
204
}
205
205
]}];
206
-
206
+
207
207
id is a required field for adding or modifying a company. A detailed description of the
208
208
[company model is available here](https://developers.intercom.io/reference/#companies-and--users)
209
-
209
+
210
210
@param attributes This is a dictionary containing key/value pairs for multiple attributes.
211
211
@note Attributes may be either a `string`, `integer`, `double`, `unix timestamp` or `bool`.
212
212
*/
213
213
+ (void )updateUserWithAttributes : (NSDictionary *)attributes ;
214
214
215
215
/* !
216
216
Log an event with a given name.
217
-
217
+
218
218
You can log events in Intercom based on user actions in your app. Events are different
219
219
to custom user attributes in that events are information on what Users did and when they
220
220
did it, whereas custom user attributes represent the User's current state as seen in their
221
221
profile. See details about Events [here](https://developers.intercom.io/reference/#events)
222
-
222
+
223
223
@param name The name of the event that it is going to be logged.
224
224
*/
225
225
+ (void )logEventWithName : (NSString *)name ;
226
226
227
227
/* !
228
228
Metadata Objects support a few simple types that Intercom can present on your behalf, see the
229
229
[Intercom API docs](https://developers.intercom.io/reference/#event-metadata-types)
230
-
230
+
231
231
[Intercom logEventWithName:@"ordered_item" metaData:@{
232
232
@"order_date": @1392036272,
233
233
@"stripe_invoice": @"inv_3434343434",
234
234
@"order_number": @{
235
235
@"value": @"3434-3434",
236
236
@"url": @"https://example.org/orders/3434-3434"
237
237
}];
238
-
238
+
239
239
@param name The name of the event you wish to track.
240
240
@param metaData contains simple types to present to Intercom
241
241
*/
@@ -247,7 +247,7 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
247
247
248
248
/* !
249
249
Present the Intercom Messenger
250
-
250
+
251
251
Opens the Intercom messenger to automatically to the best place for your users.
252
252
*/
253
253
+ (void )presentMessenger ;
@@ -271,10 +271,10 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
271
271
/* ! @name Working with push notifications */
272
272
// =========================================================================================================
273
273
/* !
274
- Set the device token for push notifications. Once the device token is set, the methods for receiving push
274
+ Set the device token for push notifications. Once the device token is set, the methods for receiving push
275
275
notifications are safely swizzled so ones sent from Intercom can be intercepted. When a push notification from
276
276
Intercom is received, Intercom for iOS will automatically launch the message from the notification.
277
-
277
+
278
278
@param deviceToken The device token provided in the `didRegisterForRemoteNotificationsWithDeviceToken` method.
279
279
*/
280
280
+ (void )setDeviceToken : (NSData *)deviceToken ;
@@ -286,7 +286,7 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
286
286
/* !
287
287
This method allows you to set a fixed bottom padding for in app messages and the launcher.
288
288
It is useful if your app has a tab bar or similar UI at the bottom of your window.
289
-
289
+
290
290
@param bottomPadding The size of the bottom padding in points.
291
291
*/
292
292
+ (void )setBottomPadding : (CGFloat)bottomPadding ;
@@ -298,19 +298,19 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
298
298
/* !
299
299
Use this to hide all incoming Intercom messages and message previews in the parts of your app where you do
300
300
not wish to interrupt users, for example Camera views, parts of a game or other scenarios.
301
-
301
+
302
302
By default, all in app messages will be visible.
303
-
303
+
304
304
@param visible A boolean indicating if in app messages should be visible.
305
305
*/
306
306
+ (void )setInAppMessagesVisible : (BOOL )visible ;
307
307
308
308
/* !
309
309
Use this to show the Intercom launcher selectively within your app. If you choose to display the launcher,
310
310
you may want to hide it on some screens where screen space is critical (e.g. parts of a game).
311
-
311
+
312
312
By default, the launcher is hidden.
313
-
313
+
314
314
@param visible A boolean indicating if the launcher should be visible.
315
315
*/
316
316
+ (void )setLauncherVisible : (BOOL )visible ;
@@ -328,7 +328,7 @@ typedef NS_ENUM(NSUInteger, ICMPreviewPosition){
328
328
/* !
329
329
This method provides the current number of unread conversations.
330
330
This is useful if you want to display a badge counter on the button where you launch Intercom.
331
-
331
+
332
332
@return The number of unread conversations.
333
333
*/
334
334
+ (NSUInteger )unreadConversationCount ;
@@ -353,7 +353,7 @@ UIKIT_EXTERN NSString *const IntercomUnreadConversationCountDidChangeNotificatio
353
353
// =========================================================================================================
354
354
355
355
/* !
356
- If you wish to change your status bar's style or visibility while an Intercom notification may be on
356
+ If you wish to change your status bar's style or visibility while an Intercom notification may be on
357
357
screen, call this method so that Intercom's window can reflect these changes accordingly.
358
358
*/
359
359
+ (void )setNeedsStatusBarAppearanceUpdate ;
@@ -383,12 +383,12 @@ UIKIT_EXTERN NSString *const IntercomUnreadConversationCountDidChangeNotificatio
383
383
/* !
384
384
These are notifications thrown by Intercom for iOS when the Intercom window is displayed and hidden or when
385
385
a new conversation has been started. These notifications are fired only when there is a change in the state
386
- of Intercom's UI: when a user receives a message for instance, willShow and didShow notifications will be
387
- fired accordingly when the Intercom Notification (chat head) is presented.
388
-
386
+ of Intercom's UI: when a user receives a message for instance, willShow and didShow notifications will be
387
+ fired accordingly when the Intercom Notification (chat head) is presented.
388
+
389
389
Once the user taps on the chat head, the message is presented in your app. It will be presented covering
390
390
the entire screen, but no notifications will be thrown here as Intercom has already been visible.
391
-
391
+
392
392
In the case of a new conversation this notification may be used to prompt users to enable push notifications.
393
393
*/
394
394
0 commit comments