React Native Headless js, модуль AppRegistry не зарегистрирован (вызывая startHeadlessTask) - PullRequest
0 голосов
/ 10 мая 2018

У меня возникла проблема с собственным фоновым обслуживанием - Безголовый JS

Я использую Expo framework

Ошибка Android Studio MSG:

E/ReactNativeJS: The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.
E/unknown:ReactNative: Unable to launch redbox because react activity is not available, here is the error that redbox would've displayed: The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.
E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling startHeadlessTask) 
E/unknown:ReactNative: Unable to launch redbox because react activity is not available, here is the error that redbox would've displayed: Module AppRegistry is not a registered callable module (calling startHeadlessTask)

API JS: (App.js)

const LockScreenOpenService = async (taskData) => {
   DeviceEventEmitter.addListener('LockScreenOpen', function(e: Event) {
      // handle event.
      console.log("== Debug: Received LockScreen View Open");
   });
};

AppRegistry.registerHeadlessTask('LockScreenOpenService', () => 
LockScreenOpenService);

LockScreenOpenService.java:

public class LockScreenOpenService extends HeadlessJsTaskService {

@Override
protected @Nullable
HeadlessJsTaskConfig getTaskConfig(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        return new HeadlessJsTaskConfig(
                "LockScreenOpenService",
                Arguments.fromBundle(extras),
                5000, // timeout for the task
                false // optional: defines whether or not  the task is allowed in foreground. Default is false
        );
    }
    return null;
}
}

Запуск службы:

 public void startLockViewService(){
  Intent listenIntent = new Intent(getApplication(), LockScreenOpenService.class);
  Bundle bundle = new Bundle();

  listenIntent.putExtras(bundle);
  startService(listenIntent);
}

AndroidManifest.xml

    <service
    android:name=".lockscreen.LockScreenOpenService"
    android:enabled="true"
    android:exported="true" />

Понятия не имею почему 'Модуль AppRegistryне зарегистрированный вызываемый модуль (вызывающий startHeadlessTask) 'произошел!?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...