3434 * callback dispatcher, used to invoke Dart callbacks while backgrounded.
3535 */
3636public class BackgroundExecutor implements MethodCallHandler {
37- private static final String TAG = "BackgroundExecutor" ;
37+ private static final String TAG = "OneSignal - BackgroundExecutor" ;
38+ private static final String CHANNEL = "OneSignalBackground" ;
39+ private static final String OSK = "one_signal_key" ;
3840 private static final String CALLBACK_HANDLE_KEY = "callback_handle" ;
3941 private static final String USER_CALLBACK_HANDLE_KEY = "user_callback_handle" ;
4042
@@ -69,7 +71,7 @@ public static void setPluginRegistrant(
6971 public static void setCallbackDispatcher (long callbackHandle ) {
7072 Context context = ContextHolder .getApplicationContext ();
7173 SharedPreferences prefs =
72- context .getSharedPreferences ("one_signal_key" , 0 );
74+ context .getSharedPreferences (OSK , 0 );
7375 prefs .edit ().putLong (CALLBACK_HANDLE_KEY , callbackHandle ).apply ();
7476 }
7577
@@ -82,7 +84,7 @@ public void onMethodCall(MethodCall call, @NonNull Result result) {
8284 // is running. From this point forward, the Android side of this plugin can send
8385 // callback handles through the background method channel, and the Dart side will execute
8486 // the Dart methods corresponding to those callback handles.
85- Log .i ("OneSignal" , "Background channel ready" );
87+ Log .i (TAG , "Background channel ready" );
8688
8789 result .success (true );
8890 } else {
@@ -128,7 +130,7 @@ private void onInitialized() {
128130 * </ul>
129131 */
130132 public void startBackgroundIsolate (IsolateStatusHandler isolate ) {
131- Log .i ("OneSignal" , "Starting background isolate." );
133+ Log .i (TAG , "Starting background isolate." );
132134 if (isNotRunning ()) {
133135 long callbackHandle = getPluginCallbackHandle ();
134136 if (callbackHandle != 0 ) {
@@ -268,7 +270,7 @@ private long getUserCallbackHandle() {
268270 }
269271 SharedPreferences prefs =
270272 ContextHolder .getApplicationContext ()
271- .getSharedPreferences ("one_signal_key" , 0 );
273+ .getSharedPreferences (OSK , 0 );
272274 return prefs .getLong (USER_CALLBACK_HANDLE_KEY , 0 );
273275 }
274276
@@ -279,7 +281,7 @@ private long getUserCallbackHandle() {
279281 public static void setUserCallbackHandle (long callbackHandle ) {
280282 Context context = ContextHolder .getApplicationContext ();
281283 SharedPreferences prefs =
282- context .getSharedPreferences ("one_signal_key" , 0 );
284+ context .getSharedPreferences (OSK , 0 );
283285 prefs .edit ().putLong (USER_CALLBACK_HANDLE_KEY , callbackHandle ).apply ();
284286 }
285287
@@ -290,15 +292,14 @@ private long getPluginCallbackHandle() {
290292 }
291293 SharedPreferences prefs =
292294 ContextHolder .getApplicationContext ()
293- .getSharedPreferences ("one_signal_key" , 0 );
295+ .getSharedPreferences (OSK , 0 );
294296 return prefs .getLong (CALLBACK_HANDLE_KEY , 0 );
295297 }
296298
297299 // This channel is responsible for sending requests from Android to Dart to execute Dart
298300 // callbacks in the background isolate.
299301 private void initializeMethodChannel (BinaryMessenger isolate ) {
300- backgroundChannel =
301- new MethodChannel (isolate , "OneSignalBackground" );
302+ backgroundChannel = new MethodChannel (isolate , CHANNEL );
302303 backgroundChannel .setMethodCallHandler (this );
303304 }
304305}
0 commit comments