@@ -105,34 +105,29 @@ private JSONObject jsonFromErrorMessageString(String errorMessage) throws JSONEx
105
105
106
106
@ ReactMethod
107
107
public void init (String appId ) {
108
- Activity activity = mReactApplicationContext .getCurrentActivity ();
108
+ Context context = mReactApplicationContext .getCurrentActivity ();
109
109
110
110
if (oneSignalInitDone ) {
111
- Log .w ("onesignal" , "Already initialized the OneSignal React-Native SDK" );
111
+ Log .e ("onesignal" , "Already initialized the OneSignal React-Native SDK" );
112
112
return ;
113
113
}
114
114
115
115
oneSignalInitDone = true ;
116
116
117
117
OneSignal .sdkType = "react" ;
118
118
119
- if (activity == null ) {
119
+ if (context == null ) {
120
120
// in some cases, especially when react-native-navigation is installed,
121
121
// the activity can be null, so we can initialize with the context instead
122
- OneSignal .init (mReactApplicationContext .getApplicationContext (),
123
- null ,
124
- appId ,
125
- new NotificationOpenedHandler (mReactContext ),
126
- new NotificationReceivedHandler (mReactContext )
127
- );
128
- } else {
129
- OneSignal .init (activity ,
130
- null ,
131
- appId ,
132
- new NotificationOpenedHandler (mReactContext ),
133
- new NotificationReceivedHandler (mReactContext )
134
- );
122
+ context = mReactApplicationContext .getApplicationContext ();
135
123
}
124
+
125
+ OneSignal .init (context ,
126
+ null ,
127
+ appId ,
128
+ new NotificationOpenedHandler (mReactContext ),
129
+ new NotificationReceivedHandler (mReactContext )
130
+ );
136
131
}
137
132
138
133
@ ReactMethod
0 commit comments