Ionic3 в iOS не может передавать координаты моему API, когда приложение находится в фоновом режиме - PullRequest
0 голосов
/ 20 февраля 2019

Я использую Ionic 3 и этот плагин cordova mauron85 / cordova-plugin-background-geolocation , но приложение не передает потоки координат, когда оно находится в фоновом режиме в iOS.

Работает в Android, эмуляторе iOS, но не в реальном iPhone.Кроме того, опция url прекращает потоковую передачу через 1 с

Пока мой код:

/**
 *
 * @param {boolean} status
 * @param {number} stepOn
 */
private registerCoords(status: boolean, stepOn?: number): void {
    let step: number = stepOn ? stepOn : 1;

    if (!STATIC.GEO_INTERVAL && status) {
        STATIC.GEO_INTERVAL = setInterval((() => {
            this.currentCoords = this.geolocationService.getCoords();
            if (!this.isNetWork) {
                this.functions.f_alertToast('Network connection lost', 0);

                return this.registerCoords(false);
            }

            if (!this.currentCoords && !this.isProcessPicture) {
                this.geoLocationEvent = false;
                this.isGeoLocation = false;
                console.warn('[HomePage] registerCoords() -> setInterval() [GPS connection lost!!]');
            }
            else if (this.currentCoords) {
                this.geoLocationEvent = true;
                this.isGeoLocation = true;
            }

            this.saveCoords(this.currentCoords, step);
            step = 1;
        }).bind(this), STATIC.GEO_TIMEOUT);

        this.finishLoad();
    }

    if (status === false) {
        clearInterval(STATIC.GEO_INTERVAL);
        STATIC.GEO_INTERVAL = null;
        this.checkGeolocation();
    }
}

config.xml

<plugin name="cordova-plugin-mauron85-background-geolocation" spec="2.3.5">
    <variable name="ICON" value="@mipmap/icon" />
    <variable name="SMALL_ICON" value="@mipmap/icon" />
    <variable name="ACCOUNT_NAME" value="@string/app_name" />
    <variable name="ACCOUNT_LABEL" value="@string/app_name" />
    <variable name="ACCOUNT_TYPE" value="$PACKAGE_NAME.account" />
    <variable name="CONTENT_AUTHORITY" value="$PACKAGE_NAME" />
    <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
    <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="23+" />
</plugin>
<plugin name="cordova-plugin-geolocation" spec="2.4.3">
    <variable name="GEOLOCATION_USAGE_DESCRIPTION" value="..." />
</plugin>

package.json

"@ionic-native/geolocation": "4.9.0",
"cordova-plugin-geolocation": "2.4.3",
"cordova-plugin-mauron85-background-geolocation": "2.3.5",
...