Skip to content

Commit cee22e6

Browse files
authored
Merge pull request #1806 from OneSignal/fix/android_logging
Fix: Android use OneSignalLog, don't use `android.util.Log`, also fixes crash
2 parents d3ee6fa + d31163a commit cee22e6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

android/src/main/java/com/onesignal/rnonesignalandroid/RNOneSignal.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ of this software and associated documentation files (the "Software"), to deal
3838
import android.content.Context;
3939
import android.content.pm.ApplicationInfo;
4040
import android.os.Bundle;
41-
import android.util.Log;
41+
import com.onesignal.debug.internal.logging.Logging;
4242
import com.facebook.react.bridge.Callback;
4343
import com.facebook.react.bridge.LifecycleEventListener;
4444
import com.facebook.react.bridge.Promise;
@@ -172,7 +172,7 @@ private void removeObservers() {
172172

173173
private void removeHandlers() {
174174
if(!oneSignalInitDone) {
175-
Log.i("OneSignal", "OneSignal React-Native SDK not initialized yet. Could not remove handlers.");
175+
Logging.debug("OneSignal React-Native SDK not initialized yet. Could not remove handlers.", null);
176176
return;
177177
}
178178

@@ -232,7 +232,7 @@ public void initialize(String appId) {
232232
OneSignalWrapper.setSdkVersion("050209");
233233

234234
if (oneSignalInitDone) {
235-
Log.e("OneSignal", "Already initialized the OneSignal React-Native SDK");
235+
Logging.debug("Already initialized the OneSignal React-Native SDK", null);
236236
return;
237237
}
238238

@@ -384,7 +384,7 @@ public void onWillDisplay(INotificationWillDisplayEvent event) {
384384
}
385385
}
386386
} catch(InterruptedException e){
387-
Log.e("InterruptedException" + e.toString(), null);
387+
Logging.error("InterruptedException: " + e.toString(), null);
388388
}
389389
} catch (JSONException e) {
390390
e.printStackTrace();
@@ -395,7 +395,7 @@ public void onWillDisplay(INotificationWillDisplayEvent event) {
395395
private void displayNotification(String notificationId){
396396
INotificationWillDisplayEvent event = notificationWillDisplayCache.get(notificationId);
397397
if (event == null) {
398-
Log.e("Could not find onWillDisplayNotification event for notification with id: " + notificationId, null);
398+
Logging.error("Could not find onWillDisplayNotification event for notification with id: " + notificationId, null);
399399
return;
400400
}
401401
event.getNotification().display();
@@ -405,7 +405,7 @@ private void displayNotification(String notificationId){
405405
private void preventDefault(String notificationId) {
406406
INotificationWillDisplayEvent event = notificationWillDisplayCache.get(notificationId);
407407
if (event == null) {
408-
Log.e("Could not find onWillDisplayNotification event for notification with id: " + notificationId, null);
408+
Logging.error("Could not find onWillDisplayNotification event for notification with id: " + notificationId, null);
409409
return;
410410
}
411411
event.preventDefault();
@@ -432,7 +432,7 @@ public void removePermissionObserver() {
432432
public void onNotificationPermissionChange(boolean permission) {
433433
try {
434434
sendEvent("OneSignal-permissionChanged", RNUtils.convertHashMapToWritableMap(RNUtils.convertPermissionToMap(permission)));
435-
Log.i("OneSignal", "sending permission change event");
435+
Logging.debug("Sending permission change event", null);
436436
} catch (JSONException e) {
437437
e.printStackTrace();
438438
}
@@ -546,7 +546,7 @@ public void onPushSubscriptionChange(PushSubscriptionChangedState pushSubscripti
546546
sendEvent("OneSignal-subscriptionChanged",
547547
RNUtils.convertHashMapToWritableMap(
548548
RNUtils.convertPushSubscriptionChangedStateToMap(pushSubscriptionChangedState)));
549-
Log.i("OneSignal", "sending subscription change event");
549+
Logging.debug("Sending subscription change event", null);
550550
} catch (JSONException e) {
551551
e.printStackTrace();
552552
}
@@ -715,7 +715,7 @@ public void onUserStateChange(UserChangedState state) {
715715
sendEvent("OneSignal-userStateChanged",
716716
RNUtils.convertHashMapToWritableMap(
717717
RNUtils.convertUserChangedStateToMap(state)));
718-
Log.i("OneSignal", "sending user state change event");
718+
Logging.debug("Sending user state change event", null);
719719
} catch (JSONException e) {
720720
e.printStackTrace();
721721
}

0 commit comments

Comments
 (0)