transistorsoft / cordova-plugin-background-fetch

Implements background fetching of data.
MIT License
296 stars 80 forks source link

iOS get TSBackgroundFetch addListener:callback:timeout when call BackgroundGeolocation.ready() #154

Closed GrupoPrides closed 3 years ago

GrupoPrides commented 3 years ago

Your Environment

info.plist

<key>BGTaskSchedulerPermittedIdentifiers</key>
    <array>
        <string>com.transistorsoft.fetch</string>
    </array>

and

<key>UIBackgroundModes</key>
    <array>
        <string>audio</string>
        <string>fetch</string>
        <string>location</string>
        <string>remote-notification</string>
    </array>

AppDelegate.swift

import TSBackgroundFetch

// Added for cordova-plugin-background-fetch
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler:@escaping (UIBackgroundFetchResult) -> Void) {
  NSLog("AppDelegate received fetch event");
  TSBackgroundFetch.sharedInstance().perform(completionHandler: completionHandler, applicationState: application.applicationState);
}

Expected Behavior

Application start process of obtaining locations and send them the specified url, just as it does in android.

Actual Behavior

I get this exception Thread 1: "-[TSBackgroundFetch addListener:callback:timeout:]: unrecognized selector sent to instance 0x283236480" image

Steps to Reproduce

  1. Run app and call method to execute BackgroundGeolocation.ready
  2. Crash app (only iOS fail)

Context

Debug logs

christocracy commented 3 years ago

What version XCode are you using?

GrupoPrides commented 3 years ago

Hi, XCode Version = 13.0 (13A233)

christocracy commented 3 years ago

Show me your package.json

GrupoPrides commented 3 years ago

But @christocracy this morning I'm upgraded Capacitor to version 3, and update plugins from Cordova to Capacitor, and error ir gone. The only error y getting right now with the new version is:

Thread 1: "*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]" when I try to execute this:

      .finally(() => {
        this.exportingLog = false;
        this.commonService.showToastTop('Log de rutas exportado correctamente');
      })
      .catch(() => {
        this.exportingLog = true;
        this.commonService.showToastTop('Ocurrio un error al exportar el log de rutas');
      });

in any case here is my old package.json

  "name": "mandaditos_cr_mensajero",
  "version": "1.28",
  "author": "Oscar Mora with ionic framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "prod": "ng run app:build:production"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@capacitor-community/fcm": "^1.1.2",
    "@capacitor/android": "^2.4.8",
    "@capacitor/core": "^2.4.8",
    "@capacitor/ios": "^2.4.8",
    "@ionic-native/android-permissions": "^5.26.0",
    "@ionic-native/background-mode": "^5.28.0",
    "@ionic-native/core": "^5.0.7",
    "@ionic-native/geolocation": "^5.28.0",
    "@ionic-native/launch-navigator": "^5.26.0",
    "@ionic-native/market": "^5.30.0",
    "@ionic-native/native-audio": "^5.24.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^5.0.0",
    "@microsoft/applicationinsights-web": "^2.6.3",
    "@types/googlemaps": "^3.39.6",
    "@types/signalr": "^2.2.36",
    "angular-emojify": "^1.0.0",
    "angularx-qrcode": "^2.3.4",
    "chart.js": "^2.9.3",
    "cordova-background-geolocation-lt": "^4.3.0",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-android-permissions": "^1.0.2",
    "cordova-plugin-background-fetch": "^6.1.1",
    "cordova-plugin-background-mode": "^0.7.3",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-dialogs": "^2.0.2",
    "cordova-plugin-geolocation": "^4.0.2",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "ionic4-rating": "^1.0.9",
    "jquery": "^3.5.0",
    "moment": "^2.27.0",
    "ng-otp-input": "^1.7.1",
    "ng2-signalr": "^10.0.2",
    "ngx-filter-pipe": "^2.1.2",
    "ngx-mask": "^9.1.2",
    "ngx-pipes": "^2.7.3",
    "ngx-simple-crypt": "^1.0.1",
    "rxjs": "~6.5.1",
    "signalr": "^2.4.1",
    "signalr-no-jquery": "^0.1.10",
    "tslib": "^1.10.0",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.4",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.5",
    "@angular/cli": "9.1.15",
    "@angular/compiler": "~9.1.6",
    "@angular/compiler-cli": "~9.1.6",
    "@angular/language-service": "~9.1.6",
    "@capacitor/cli": "^2.4.7",
    "@ionic/angular-toolkit": "^2.1.1",
    "@ionic/lab": "3.2.10",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  },
  "description": "An Ionic project"
}

Thanks..!

christocracy commented 3 years ago

"cordova-background-geolocation-lt": "^4.3.0", "cordova-plugin-background-fetch": "^6.1.1",

What version of background-fetch does background-geolocation@4.3.0 want

GrupoPrides commented 3 years ago

oh I see, I needed fetch version 7.0.1 ...

Thanks..

Now las question, if I'm upgrade my Capacitor to version 3, Can I still using my old buyed key?

christocracy commented 3 years ago

Can I still using my old buyed key?

No. You will need a Capacitor Background Geolocation license.