Skip to content

Commit b2d8972

Browse files
piotr pietruszewskipi0trpietruszewski
authored andcommitted
fix(ios): added version header for manual linked wrapper
1 parent 90a341a commit b2d8972

File tree

2 files changed

+70
-42
lines changed

2 files changed

+70
-42
lines changed

ios/Intercom.xcodeproj/project.pbxproj

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
3A6572C897F85E4E8295FC2D /* IntercomEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A657CFB9FBFC5F094B4D20D /* IntercomEventEmitter.m */; };
11-
3A6576B390F8276AE2651D35 /* IntercomAttributesBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A6576960DB107666B27C442 /* IntercomAttributesBuilder.m */; };
12-
7D72E2FD26611EAB00A3C250 /* IntercomModule.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* IntercomModule.m */; };
13-
7DAD57C02683B5B5001B040A /* IntercomHelpCenterHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAD57BF2683B5B5001B040A /* IntercomHelpCenterHelpers.m */; };
10+
7DC6AEF02689C2060031A854 /* IntercomHelpCenterHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAD57BF2683B5B5001B040A /* IntercomHelpCenterHelpers.m */; };
11+
7DC6AEF32689C2060031A854 /* IntercomModule.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* IntercomModule.m */; };
12+
7DC6AEF42689C2060031A854 /* IntercomAttributesBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A6576960DB107666B27C442 /* IntercomAttributesBuilder.m */; };
13+
7DC6AEF62689C2060031A854 /* IntercomEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A657CFB9FBFC5F094B4D20D /* IntercomEventEmitter.m */; };
1414
/* End PBXBuildFile section */
1515

1616
/* Begin PBXCopyFilesBuildPhase section */
@@ -89,6 +89,7 @@
8989
58B511D71A9E6C8500147676 /* Sources */,
9090
58B511D81A9E6C8500147676 /* Frameworks */,
9191
58B511D91A9E6C8500147676 /* CopyFiles */,
92+
7D9483062689ED1B005A1514 /* Export Intercom Version */,
9293
);
9394
buildRules = (
9495
);
@@ -131,15 +132,36 @@
131132
};
132133
/* End PBXProject section */
133134

135+
/* Begin PBXShellScriptBuildPhase section */
136+
7D9483062689ED1B005A1514 /* Export Intercom Version */ = {
137+
isa = PBXShellScriptBuildPhase;
138+
buildActionMask = 2147483647;
139+
files = (
140+
);
141+
inputFileListPaths = (
142+
);
143+
inputPaths = (
144+
);
145+
name = "Export Intercom Version";
146+
outputFileListPaths = (
147+
);
148+
outputPaths = (
149+
);
150+
runOnlyForDeploymentPostprocessing = 0;
151+
shellPath = /bin/sh;
152+
shellScript = "export INTERCOM_RN_VERSION=$(cat ../package.json \\\n | grep version \\\n | head -1 \\\n | awk -F: '{ print $2 }' \\\n | sed 's/[\",]//g')\n \n\nplutil -replace IntercomRnVersion -string $INTERCOM_RN_VERSION $SOURCE_ROOT/../../../../ios/Rn59SampleApp/Info.plist\n";
153+
};
154+
/* End PBXShellScriptBuildPhase section */
155+
134156
/* Begin PBXSourcesBuildPhase section */
135157
58B511D71A9E6C8500147676 /* Sources */ = {
136158
isa = PBXSourcesBuildPhase;
137159
buildActionMask = 2147483647;
138160
files = (
139-
7DAD57C02683B5B5001B040A /* IntercomHelpCenterHelpers.m in Sources */,
140-
7D72E2FD26611EAB00A3C250 /* IntercomModule.m in Sources */,
141-
3A6576B390F8276AE2651D35 /* IntercomAttributesBuilder.m in Sources */,
142-
3A6572C897F85E4E8295FC2D /* IntercomEventEmitter.m in Sources */,
161+
7DC6AEF02689C2060031A854 /* IntercomHelpCenterHelpers.m in Sources */,
162+
7DC6AEF32689C2060031A854 /* IntercomModule.m in Sources */,
163+
7DC6AEF42689C2060031A854 /* IntercomAttributesBuilder.m in Sources */,
164+
7DC6AEF62689C2060031A854 /* IntercomEventEmitter.m in Sources */,
143165
);
144166
runOnlyForDeploymentPostprocessing = 0;
145167
};

ios/IntercomModule.m

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@ @implementation IntercomModule
2222

2323
+ (void)initialize:(nonnull NSString *)apiKey withAppId:(nonnull NSString *)appId {
2424
NSString *version = @"0";
25-
25+
2626
NSString *path = [[NSBundle mainBundle] pathForResource:@"IntercomFramework" ofType:@"bundle"];
2727
NSBundle *bundle = [NSBundle bundleWithPath:path];
2828
if (bundle != nil) {
2929
NSString *v = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
3030
if (v != nil) {
3131
version = v;
3232
}
33+
} else {
34+
bundle = [NSBundle mainBundle];
35+
NSString *v = [bundle objectForInfoDictionaryKey:@"IntercomRnVersion"];
36+
if (v != nil) {
37+
version = v;
38+
}
3339
}
34-
40+
3541
[Intercom setReactNativeVersion:version];
3642
[Intercom setApiKey:apiKey forAppId:appId];
3743
NSLog(@"initialized Intercom module");
@@ -43,7 +49,7 @@ + (void)setDeviceToken:(nonnull NSData *)deviceToken {
4349
}
4450

4551
+ (BOOL)isIntercomPushNotification:(NSDictionary *)userInfo {
46-
52+
4753
return [Intercom isIntercomPushNotification:userInfo];
4854
}
4955

@@ -72,7 +78,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
7278
@try {
7379
NSData *data = [self dataFromHexString:token];
7480
[Intercom setDeviceToken:data];
75-
81+
7682
NSLog(@"sendTokenToIntercom");
7783
resolve(@(YES));
7884
} @catch (NSException *exception) {
@@ -82,7 +88,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
8288

8389
RCT_EXPORT_METHOD(registerUnidentifiedUser:
8490
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
85-
91+
8692
[Intercom registerUnidentifiedUser];
8793
NSLog(@"registerUnidentifiedUser");
8894
resolve(@(YES));
@@ -94,11 +100,11 @@ - (NSData *)dataFromHexString:(NSString *)string {
94100
{
95101
NSString *userId = options[@"userId"];
96102
NSString *userEmail = options[@"email"];
97-
103+
98104
if ([userId isKindOfClass:[NSNumber class]]) {
99105
userId = [(NSNumber *) userId stringValue];
100106
}
101-
107+
102108
if (userId.length > 0 && userEmail.length > 0) {
103109
[Intercom registerUserWithUserId:userId email:userEmail];
104110
NSLog(@"registerUserWithUserId");
@@ -120,7 +126,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
120126

121127
RCT_EXPORT_METHOD(logout:
122128
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
123-
129+
124130
[Intercom logout];
125131
NSLog(@"logout");
126132
resolve(@(YES));
@@ -131,21 +137,21 @@ - (NSData *)dataFromHexString:(NSString *)string {
131137
@try {
132138
ICMUserAttributes *userAttributes = [IntercomAttributesBuilder userAttributesForDictionary:options];
133139
[Intercom updateUser:userAttributes];
134-
140+
135141
NSLog(@"updateUser");
136142
resolve(@(YES));
137143
} @catch (NSException *exception) {
138144
reject(UPDATE_USER, @"Error in updateUser", [self exceptionToError:exception :UPDATE_USER :@"updateUser"]);
139145
}
140-
141-
146+
147+
142148
};
143149

144150
RCT_EXPORT_METHOD(setUserHash:
145151
(NSString *) userHash: (RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
146152
@try {
147153
[Intercom setUserHash:userHash];
148-
154+
149155
NSLog(@"setUserHash");
150156
resolve(@(YES));
151157
} @catch (NSException *exception) {
@@ -162,13 +168,13 @@ - (NSData *)dataFromHexString:(NSString *)string {
162168
if (eventName == @"") {
163169
@throw[NSException exceptionWithName:@"Invalid eventName" reason:@"eventName can't be empty" userInfo:nil];
164170
}
165-
171+
166172
if ([metaData isKindOfClass:[NSDictionary class]] && metaData.count > 0) {
167173
[Intercom logEventWithName:eventName metaData:metaData];
168174
} else {
169175
[Intercom logEventWithName:eventName];
170176
}
171-
177+
172178
NSLog(@"logEvent");
173179
resolve(@(YES));
174180
} @catch (NSException *exception) {
@@ -180,7 +186,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
180186
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
181187
@try {
182188
NSUInteger count = [Intercom unreadConversationCount];
183-
189+
184190
NSLog(@"unreadConversationCount");
185191
resolve(@(count));
186192
} @catch (NSException *exception) {
@@ -190,7 +196,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
190196

191197
RCT_EXPORT_METHOD(displayMessenger:
192198
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
193-
199+
194200
[Intercom presentMessenger];
195201
NSLog(@"displayMessenger");
196202
resolve(@(YES));
@@ -199,15 +205,15 @@ - (NSData *)dataFromHexString:(NSString *)string {
199205
RCT_EXPORT_METHOD(displayMessageComposer:
200206
(NSString *) initialMessage:
201207
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
202-
208+
203209
[Intercom presentMessageComposer:initialMessage];
204210
NSLog(@"displayMessageComposer");
205211
resolve(@(YES));
206212
};
207213

208214
RCT_EXPORT_METHOD(displayHelpCenter:
209215
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
210-
216+
211217
[Intercom presentHelpCenter];
212218
NSLog(@"displayHelpCenter");
213219
resolve(@(YES));
@@ -216,7 +222,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
216222
RCT_EXPORT_METHOD(displayCarousel:
217223
(NSString *) carouselId:
218224
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
219-
225+
220226
[Intercom presentCarousel:carouselId];
221227
NSLog(@"displayCarousel");
222228
resolve(@(YES));
@@ -225,7 +231,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
225231
RCT_EXPORT_METHOD(displayArticle:
226232
(NSString *) articleId:
227233
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
228-
234+
229235
[Intercom presentArticle:articleId];
230236
NSLog(@"displayArticle");
231237
resolve(@(YES));
@@ -234,7 +240,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
234240
RCT_EXPORT_METHOD(displayHelpCenterCollections:
235241
(NSArray *) collectionsId:
236242
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
237-
243+
238244
[Intercom presentHelpCenterCollections:collectionsId];
239245
NSLog(@"displayHelpCenterCollections");
240246
resolve(@(YES));
@@ -245,19 +251,19 @@ - (NSData *)dataFromHexString:(NSString *)string {
245251
NSLog(@"fetchHelpCenterCollections");
246252
@try {
247253
[Intercom fetchHelpCenterCollectionsWithCompletion:^(NSArray<ICMHelpCenterCollection *> *_Nullable collections, NSError *_Nullable error) {
248-
254+
249255
if (collections != nil) {
250256
NSArray *parsedCollections = [IntercomHelpCenterHelpers parseCollectionsToArray:collections];
251257
resolve(parsedCollections);
252258
} else {
253259
reject(FETCH_HELP_CENTER_COLLECTIONS, @"Error in fetchHelpCenterCollections", error);
254-
260+
255261
}
256262
}];
257263
} @catch (NSException *exception) {
258264
reject(FETCH_HELP_CENTER_COLLECTIONS, @"Error in fetchHelpCenterCollections", [self exceptionToError:exception :FETCH_HELP_CENTER_COLLECTIONS :@"fetchHelpCenterCollections"]);
259265
}
260-
266+
261267
};
262268

263269
RCT_EXPORT_METHOD(fetchHelpCenterCollection:
@@ -275,15 +281,15 @@ - (NSData *)dataFromHexString:(NSString *)string {
275281
} else {
276282
reject(FETCH_HELP_CENTER_COLLECTION, @"Error in fetchHelpCenterCollection", error);
277283
}
278-
279-
284+
285+
280286
}];
281287
} @catch (NSException *exception) {
282288
reject(FETCH_HELP_CENTER_COLLECTION, @"Error in fetchHelpCenterCollection", [self exceptionToError:exception :FETCH_HELP_CENTER_COLLECTION :@"fetchHelpCenterCollection"]);
283289
}
284-
290+
285291
}
286-
292+
287293
};
288294

289295
RCT_EXPORT_METHOD(searchHelpCenter:
@@ -311,22 +317,22 @@ - (NSData *)dataFromHexString:(NSString *)string {
311317

312318
RCT_EXPORT_METHOD(hideIntercom:
313319
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
314-
320+
315321
[Intercom hideIntercom];
316322
NSLog(@"hideIntercom");
317323
resolve(@(YES));
318324
};
319325

320326
RCT_EXPORT_METHOD(setBottomPadding:(nonnull NSNumber*) bottomPadding:
321327
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
322-
328+
323329
[Intercom setBottomPadding:[bottomPadding doubleValue]];
324330
NSLog(@"setBottomPadding");
325331
resolve(@(YES));
326332
};
327333

328334
RCT_EXPORT_METHOD(setLauncherVisibility:(NSString *) visibility:(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
329-
335+
330336
BOOL visible = NO;
331337
if ([visibility isEqualToString:@"VISIBLE"]) {
332338
visible = YES;
@@ -339,7 +345,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
339345
RCT_EXPORT_METHOD(setInAppMessageVisibility:
340346
(NSString *) visibility:
341347
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
342-
348+
343349
BOOL visible = NO;
344350
if ([visibility isEqualToString:@"VISIBLE"]) {
345351
visible = YES;
@@ -352,7 +358,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
352358
RCT_EXPORT_METHOD(setLogLevel:
353359
(NSString *) param:
354360
(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock)reject) {
355-
361+
356362
[Intercom enableLogging];
357363
NSLog(@"setLogLevel");
358364
resolve(@(YES));
@@ -366,7 +372,7 @@ - (NSError *)exceptionToError:(NSException *)exception :(NSString *)code :(NSStr
366372
[info setValue:exception.callStackReturnAddresses forKey:@"ExceptionCallStackReturnAddresses"];
367373
[info setValue:exception.callStackSymbols forKey:@"ExceptionCallStackSymbols"];
368374
[info setValue:exception.userInfo forKey:@"ExceptionUserInfo"];
369-
375+
370376
return [[NSError alloc] initWithDomain:domain code:[code integerValue] userInfo:info];
371377
};
372378
@end

0 commit comments

Comments
 (0)