@@ -71,7 +71,15 @@ public static boolean isIntercomPush(RemoteMessage remoteMessage) {
7171 public static void handleRemotePushWithCustomStack (@ NonNull Application application , RemoteMessage remoteMessage ,
7272 TaskStackBuilder customStack ) {
7373 try {
74+ if (remoteMessage == null ) {
75+ Log .w (NAME , "handleRemotePushWithCustomStack: remoteMessage is null" );
76+ return ;
77+ }
7478 Map <String , String > message = remoteMessage .getData ();
79+ if (message == null ) {
80+ Log .w (NAME , "handleRemotePushWithCustomStack: message is null" );
81+ return ;
82+ }
7583 intercomPushClient .handlePushWithCustomStack (application , message , customStack );
7684 } catch (Exception err ) {
7785 Log .e (NAME , "handlePushWithCustomStack error:" );
@@ -94,8 +102,17 @@ public static void handleRemotePushMessage(@NonNull Application application, Rem
94102 }
95103
96104 public static void sendTokenToIntercom (Application application , @ NonNull String token ) {
97- intercomPushClient .sendTokenToIntercom (application , token );
98- Log .d (NAME , "sendTokenToIntercom" );
105+ if (application == null || token == null || token .isEmpty ()) {
106+ Log .w (NAME , "sendTokenToIntercom: application or token is null or empty" );
107+ return ;
108+ }
109+ try {
110+ intercomPushClient .sendTokenToIntercom (application , token );
111+ Log .d (NAME , "sendTokenToIntercom" );
112+ } catch (Exception err ) {
113+ Log .e (NAME , "sendTokenToIntercom error:" );
114+ Log .e (NAME , err .toString ());
115+ }
99116 }
100117
101118 @ ReactMethod
@@ -114,14 +131,20 @@ public void handlePushMessage(Promise promise) {
114131 @ ReactMethod
115132 public void sendTokenToIntercom (@ NonNull String token , Promise promise ) {
116133 try {
134+ if (token == null || token .isEmpty ()) {
135+ Log .w (NAME , "sendTokenToIntercom: token is null or empty" );
136+ promise .reject (IntercomErrorCodes .SEND_TOKEN_TO_INTERCOM , "token is null or empty" );
137+ return ;
138+ }
117139 Activity activity = getCurrentActivity ();
118- if (activity != null ) {
140+ if (activity != null && activity . getApplication () != null ) {
119141 intercomPushClient .sendTokenToIntercom (activity .getApplication (), token );
120142 Log .d (NAME , "sendTokenToIntercom" );
121143 promise .resolve (true );
122144 } else {
123145 Log .e (NAME , "sendTokenToIntercom" );
124146 Log .e (NAME , "no current activity" );
147+ promise .reject (IntercomErrorCodes .SEND_TOKEN_TO_INTERCOM , "no current activity" );
125148 }
126149
127150 } catch (Exception err ) {
@@ -521,7 +544,7 @@ public void setLauncherVisibility(String visibility, Promise promise) {
521544 @ ReactMethod
522545 public void setBottomPadding (double paddingBottom , Promise promise ) {
523546 try {
524- Intercom .client ().setBottomPadding ((int )paddingBottom );
547+ Intercom .client ().setBottomPadding ((int ) paddingBottom );
525548 Log .d (NAME , "setBottomPadding" );
526549 promise .resolve (true );
527550 } catch (Exception err ) {
0 commit comments