Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions android/src/newarch/IntercomModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ public static boolean isIntercomPush(RemoteMessage remoteMessage) {
public static void handleRemotePushWithCustomStack(@NonNull Application application, RemoteMessage remoteMessage,
TaskStackBuilder customStack) {
try {
if (remoteMessage == null) {
Log.w(NAME, "handleRemotePushWithCustomStack: remoteMessage is null");
return;
}
Map<String, String> message = remoteMessage.getData();
if (message == null) {
Log.w(NAME, "handleRemotePushWithCustomStack: message is null");
return;
}
intercomPushClient.handlePushWithCustomStack(application, message, customStack);
} catch (Exception err) {
Log.e(NAME, "handlePushWithCustomStack error:");
Expand All @@ -94,8 +102,17 @@ public static void handleRemotePushMessage(@NonNull Application application, Rem
}

public static void sendTokenToIntercom(Application application, @NonNull String token) {
intercomPushClient.sendTokenToIntercom(application, token);
Log.d(NAME, "sendTokenToIntercom");
if (application == null || token == null || token.isEmpty()) {
Log.w(NAME, "sendTokenToIntercom: application or token is null or empty");
return;
}
try {
intercomPushClient.sendTokenToIntercom(application, token);
Log.d(NAME, "sendTokenToIntercom");
} catch (Exception err) {
Log.e(NAME, "sendTokenToIntercom error:");
Log.e(NAME, err.toString());
}
}

@ReactMethod
Expand All @@ -114,14 +131,20 @@ public void handlePushMessage(Promise promise) {
@ReactMethod
public void sendTokenToIntercom(@NonNull String token, Promise promise) {
try {
if (token == null || token.isEmpty()) {
Log.w(NAME, "sendTokenToIntercom: token is null or empty");
promise.reject(IntercomErrorCodes.SEND_TOKEN_TO_INTERCOM, "token is null or empty");
return;
}
Activity activity = getCurrentActivity();
if (activity != null) {
if (activity != null && activity.getApplication() != null) {
intercomPushClient.sendTokenToIntercom(activity.getApplication(), token);
Log.d(NAME, "sendTokenToIntercom");
promise.resolve(true);
} else {
Log.e(NAME, "sendTokenToIntercom");
Log.e(NAME, "no current activity");
promise.reject(IntercomErrorCodes.SEND_TOKEN_TO_INTERCOM, "no current activity");
}

} catch (Exception err) {
Expand Down Expand Up @@ -521,7 +544,7 @@ public void setLauncherVisibility(String visibility, Promise promise) {
@ReactMethod
public void setBottomPadding(double paddingBottom, Promise promise) {
try {
Intercom.client().setBottomPadding((int)paddingBottom);
Intercom.client().setBottomPadding((int) paddingBottom);
Log.d(NAME, "setBottomPadding");
promise.resolve(true);
} catch (Exception err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@intercom/intercom-react-native",
"version": "9.0.0",
"version": "9.0.1",
"description": "React Native wrapper to bridge our iOS and Android SDK",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",
Expand Down