Я работаю над приложением Ionic, которое требует геозоны для запуска в фоновом режиме.Я использую плагин cordova-plugin-geofence .Я понимаю, что JavaScript не работает в фоновом режиме и что разработчик плагинов предоставил собственный код для прослушивания переходов геозоны.
Я следовал инструкциям, но, похоже, он не работает.Переход не запускается при закрытии приложения.
Вот имя моего пакета: io.ionic.pla
.
Я поместил этот код ниже в своем манифесте Android
<receiver android:name="io.ionic.pla.TransitionReceiver">
<intent-filter>
<action android:name="com.cowbell.cordova.geofence.TRANSITION" />
</intent-filter>
</receiver>
Вот мой TransitionReceiver.java
package io.ionic.pla;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.cowbell.cordova.geofence.Gson;
import com.cowbell.cordova.geofence.GeoNotification;
public class TransitionReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String error = intent.getStringExtra("error");
if (error != null) {
//handle error
Log.println(Log.ERROR, "YourAppTAG", error);
} else {
String geofencesJson = intent.getStringExtra("transitionData");
Log.println(Log.INFO, "xxxYourAppTAG", geofencesJson);
GeoNotification[] geoNotifications = Gson.get().fromJson(geofencesJson, GeoNotification[].class);
//handle geoNotifications objects
}
}
}
Пожалуйста, помогите, ребята, мне действительно нужно, чтобы это работало.