Skip to content

Commit be8e60d

Browse files
mapierceclaudeRosie-Kennelly-1
authored
feat: add suppressProactiveContent for pre-auth carousel/survey visibility (#458)
* feat: add suppressProactiveContent for pre-auth carousel/survey visibility Adds Intercom.suppressProactiveContent(types) + a ProactiveContentType enum (Carousel, Survey). Declarative semantics: the types passed are suppressed, an empty array unsuppresses all. Bridges to the native suppressProactiveContent on both platforms — iOS via [Intercom suppressProactiveContent:], Android via Intercom.client().suppressProactiveContent(List<ContentType>). Bumps the native SDK pins to the releases that expose the API (iOS 19.7.0, Android 18.5.0) and the package to 10.4.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: document suppressProactiveContent in README Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Rosie-Kennelly-1 <rosie.kennelly@intercom.io>
1 parent 93b44fa commit be8e60d

12 files changed

Lines changed: 114 additions & 14 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,22 @@ Toggles visibility of in-app messages.
11331133

11341134
---
11351135

1136+
### `Intercom.suppressProactiveContent(types)`
1137+
1138+
Suppresses the given proactive content types (carousels and/or surveys). All proactive content is visible by default. Pass an empty array to unsuppress all types.
1139+
1140+
### Options
1141+
1142+
| Type | Type | Required |
1143+
| ----- | --------------------------------------------- | -------- |
1144+
| types | array of strings `CAROUSEL, SURVEY` | yes |
1145+
1146+
### Returns
1147+
1148+
`Promise<boolean>`
1149+
1150+
---
1151+
11361152
### `Intercom.setLauncherVisibility(visibility)`
11371153

11381154
Toggles visibility of the launcher view. Set as Intercom.Visibility.GONE to hide the launcher when you don't want it to

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ dependencies {
8484
//noinspection GradleDynamicVersion
8585
implementation "com.facebook.react:react-native:+" // From node_modules
8686
implementation "com.google.firebase:firebase-messaging:24.1.2"
87-
implementation 'io.intercom.android:intercom-sdk:18.3.2'
88-
implementation 'io.intercom.android:intercom-sdk-ui:18.3.2'
87+
implementation 'io.intercom.android:intercom-sdk:18.5.0'
88+
implementation 'io.intercom.android:intercom-sdk-ui:18.5.0'
8989
}

android/src/main/java/com/intercom/reactnative/IntercomErrorCodes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class IntercomErrorCodes {
1717
public static final String DISPLAY_CONTENT = "203";
1818
public static final String SET_IN_APP_MESSAGE_VISIBILITY = "205";
1919
public static final String HIDE_INTERCOM = "206";
20+
public static final String SUPPRESS_PROACTIVE_CONTENT = "207";
2021
public static final String SET_LAUNCHER_VISIBILITY = "208";
2122
public static final String SET_BOTTOM_PADDING = "209";
2223
public static final String SET_THEME_MODE = "210";

android/src/newarch/IntercomModule.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import com.facebook.react.bridge.ReactApplicationContext;
1212
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1313
import com.facebook.react.bridge.ReactMethod;
14+
import com.facebook.react.bridge.ReadableArray;
1415
import com.facebook.react.bridge.ReadableMap;
1516
import com.facebook.react.module.annotations.ReactModule;
1617
import com.google.firebase.messaging.RemoteMessage;
1718

1819
import org.jetbrains.annotations.NotNull;
1920

21+
import java.util.ArrayList;
2022
import java.util.List;
2123
import java.util.Map;
2224

@@ -495,6 +497,28 @@ public void setInAppMessageVisibility(String visibility, Promise promise) {
495497
}
496498
}
497499

500+
@ReactMethod
501+
public void suppressProactiveContent(ReadableArray types, Promise promise) {
502+
try {
503+
List<Intercom.ContentType> contentTypes = new ArrayList<>();
504+
for (int i = 0; i < types.size(); i++) {
505+
String type = types.getString(i);
506+
if ("CAROUSEL".equals(type)) {
507+
contentTypes.add(Intercom.ContentType.CAROUSEL);
508+
} else if ("SURVEY".equals(type)) {
509+
contentTypes.add(Intercom.ContentType.SURVEY);
510+
}
511+
}
512+
Intercom.client().suppressProactiveContent(contentTypes);
513+
Log.d(NAME, "suppressProactiveContent");
514+
promise.resolve(true);
515+
} catch (Exception err) {
516+
Log.e(NAME, "suppressProactiveContent error:");
517+
Log.e(NAME, err.toString());
518+
promise.reject(IntercomErrorCodes.SUPPRESS_PROACTIVE_CONTENT, err.toString());
519+
}
520+
}
521+
498522
@ReactMethod
499523
public void hideIntercom(Promise promise) {
500524
try {

android/src/oldarch/IntercomModule.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import com.facebook.react.bridge.ReactApplicationContext;
1212
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1313
import com.facebook.react.bridge.ReactMethod;
14+
import com.facebook.react.bridge.ReadableArray;
1415
import com.facebook.react.bridge.ReadableMap;
1516
import com.facebook.react.module.annotations.ReactModule;
1617
import com.google.firebase.messaging.RemoteMessage;
1718

1819
import org.jetbrains.annotations.NotNull;
1920

21+
import java.util.ArrayList;
2022
import java.util.List;
2123
import java.util.Map;
2224

@@ -473,6 +475,28 @@ public void setInAppMessageVisibility(String visibility, Promise promise) {
473475
}
474476
}
475477

478+
@ReactMethod
479+
public void suppressProactiveContent(ReadableArray types, Promise promise) {
480+
try {
481+
List<Intercom.ContentType> contentTypes = new ArrayList<>();
482+
for (int i = 0; i < types.size(); i++) {
483+
String type = types.getString(i);
484+
if ("CAROUSEL".equals(type)) {
485+
contentTypes.add(Intercom.ContentType.CAROUSEL);
486+
} else if ("SURVEY".equals(type)) {
487+
contentTypes.add(Intercom.ContentType.SURVEY);
488+
}
489+
}
490+
Intercom.client().suppressProactiveContent(contentTypes);
491+
Log.d(NAME, "suppressProactiveContent");
492+
promise.resolve(true);
493+
} catch (Exception err) {
494+
Log.e(NAME, "suppressProactiveContent error:");
495+
Log.e(NAME, err.toString());
496+
promise.reject(IntercomErrorCodes.SUPPRESS_PROACTIVE_CONTENT, err.toString());
497+
}
498+
}
499+
476500
@ReactMethod
477501
public void hideIntercom(Promise promise) {
478502
try {

examples/example/ios/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ PODS:
88
- hermes-engine (0.81.1):
99
- hermes-engine/Pre-built (= 0.81.1)
1010
- hermes-engine/Pre-built (0.81.1)
11-
- Intercom (19.6.4)
12-
- intercom-react-native (10.3.4):
11+
- Intercom (19.7.0)
12+
- intercom-react-native (10.4.0):
1313
- boost
1414
- DoubleConversion
1515
- fast_float
1616
- fmt
1717
- glog
1818
- hermes-engine
19-
- Intercom (~> 19.6.4)
19+
- Intercom (~> 19.7.0)
2020
- RCT-Folly
2121
- RCT-Folly/Fabric
2222
- RCTRequired
@@ -2560,8 +2560,8 @@ SPEC CHECKSUMS:
25602560
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
25612561
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
25622562
hermes-engine: 4f8246b1f6d79f625e0d99472d1f3a71da4d28ca
2563-
Intercom: 74f3d48568d61f70c5bbcbcf2a07567a4349c4fc
2564-
intercom-react-native: 7573fd7ba9c1f23ab96de02dcd0bfb5033e7903a
2563+
Intercom: a14e32c294ee3402cb0adddacf3de8b22730d779
2564+
intercom-react-native: 6e11ae0c7a0e29ec01ed281bd1953e89c9296b7c
25652565
RCT-Folly: 59ec0ac1f2f39672a0c6e6cecdd39383b764646f
25662566
RCTDeprecation: c4b9e2fd0ab200e3af72b013ed6113187c607077
25672567
RCTRequired: e97dd5dafc1db8094e63bc5031e0371f092ae92a

examples/with-notifications/ios/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ PODS:
88
- hermes-engine (0.81.1):
99
- hermes-engine/Pre-built (= 0.81.1)
1010
- hermes-engine/Pre-built (0.81.1)
11-
- Intercom (19.6.4)
12-
- intercom-react-native (10.3.4):
11+
- Intercom (19.7.0)
12+
- intercom-react-native (10.4.0):
1313
- boost
1414
- DoubleConversion
1515
- fast_float
1616
- fmt
1717
- glog
1818
- hermes-engine
19-
- Intercom (~> 19.6.4)
19+
- Intercom (~> 19.7.0)
2020
- RCT-Folly
2121
- RCT-Folly/Fabric
2222
- RCTRequired
@@ -2773,8 +2773,8 @@ SPEC CHECKSUMS:
27732773
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
27742774
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
27752775
hermes-engine: 4f8246b1f6d79f625e0d99472d1f3a71da4d28ca
2776-
Intercom: 74f3d48568d61f70c5bbcbcf2a07567a4349c4fc
2777-
intercom-react-native: 7573fd7ba9c1f23ab96de02dcd0bfb5033e7903a
2776+
Intercom: a14e32c294ee3402cb0adddacf3de8b22730d779
2777+
intercom-react-native: 6e11ae0c7a0e29ec01ed281bd1953e89c9296b7c
27782778
MMKV: 7b5df6a8bf785c6705cc490c541b9d8a957c4a64
27792779
MMKVCore: 3f40b896e9ab522452df9df3ce983471aa2449ba
27802780
RCT-Folly: 59ec0ac1f2f39672a0c6e6cecdd39383b764646f

intercom-react-native.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
1919

2020
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
2121

22-
s.dependency "Intercom", '~> 19.6.4'
22+
s.dependency "Intercom", '~> 19.7.0'
2323

2424
is_new_arch_enabled = ENV["RCT_NEW_ARCH_ENABLED"] == "1"
2525
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

ios/IntercomModule.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,25 @@ - (NSData *)dataFromHexString:(NSString *)string {
374374
resolve(@(YES));
375375
};
376376

377+
RCT_EXPORT_METHOD(suppressProactiveContent:(NSArray *)types
378+
resolver:(RCTPromiseResolveBlock)resolve
379+
rejecter:(RCTPromiseRejectBlock)reject) {
380+
381+
NSMutableArray<NSNumber *> *mappedTypes = [NSMutableArray array];
382+
for (id type in types) {
383+
if (![type isKindOfClass:[NSString class]]) {
384+
continue;
385+
}
386+
if ([type isEqualToString:@"CAROUSEL"]) {
387+
[mappedTypes addObject:@(IntercomProactiveContentTypeCarousel)];
388+
} else if ([type isEqualToString:@"SURVEY"]) {
389+
[mappedTypes addObject:@(IntercomProactiveContentTypeSurvey)];
390+
}
391+
}
392+
[Intercom suppressProactiveContent:mappedTypes];
393+
resolve(@(YES));
394+
};
395+
377396

378397
#pragma mark - Unread Conversation Count
379398

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@intercom/intercom-react-native",
3-
"version": "10.3.4",
3+
"version": "10.4.0",
44
"description": "React Native wrapper to bridge our iOS and Android SDK",
55
"source": "./src/index.tsx",
66
"main": "./lib/commonjs/index.js",

0 commit comments

Comments
 (0)