You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AppDelegate.swift i don't need the notificatons part
importUIKitimportCapacitorimportCapacitorBackgroundRunnerimportWonderPush
@UIApplicationMainclassAppDelegate: UIResponder,UIApplicationDelegate{varwindow: UIWindow?
funcapplication(_application: UIApplication,didFinishLaunchingWithOptionslaunchOptions: [UIApplication.LaunchOptionsKey: Any]?)->Bool{// Override point for customization after application launch.BackgroundRunnerPlugin.registerBackgroundTask()BackgroundRunnerPlugin.handleApplicationDidFinishLaunching(launchOptions: launchOptions)returntrue}
runner.js
addEventListener('checkIn',async(resolve,reject,args)=>{try{if(args&&typeofargs.identifier!=='undefined'){awaitCapacitorKV.set('radius',args.radius)awaitCapacitorKV.set('language',args.language)awaitCapacitorKV.set('identifier',args.identifier)}constpush=awaitCapacitorKV.get('identifier').value;constradius=awaitCapacitorKV.get('radius').valueconstlanguage=awaitCapacitorKV.get('language').valueconstlocation=awaitCapacitorGeolocation.getCurrentPosition();// const location = {// latitude: 45.565656,// longitude: 45.5656565,// };console.log('this is my location '+JSON.stringify(location))constlat=location.latitudeconstlng=location.longitudeconstbody=`identifier=${push}&radius=${radius}&language=${language}&lat=${lat}&lng=${lng}`;console.log("location lat: "+lat);console.log("location lng: "+lng);console.log("language: "+language);console.log("radius: "+radius);constresponse=awaitfetch('https://my.endpoint',{method: 'POST',headers: {Accept: 'application/json',Authorization: `Bearer token`,},body: body})constmessage=awaitresponse.json()console.log(JSON.stringify(message))if(response.ok){console.log('Fetch is working!')}else{console.log('There is an error with the fetch function')}resolve(message)}catch(err){console.error(err);reject(err);}});
Info.plist
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>ro.patrimonium.opla.task</string>
</array>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We need to track your location while your device is locked in order to notify you when you are close to a monument.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) uses location services to track your location in order to notify you when you are close to a monument</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) uses location services to track your location in order to notify you when you are close to a monument</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>location</string>
<string>processing</string>
<string>remote-notification</string>
</array>
And now comes the interesting part, if i dispatch the event from the app when it's state is active all is working ok, i am getting the location and it is sent to the dashboard, but when a send the app in background i have 2 strange problems:
I am using xcode to build the app and send it to my device (not simulator) and i am monitoring the logs in xcode, the background runner is getting called but i am getting an error for the location, CapacitorGeolocation.getCurrentPosition() cant get my location, all the permissions are allowed, but when the permission promt comes up i cant choose location always only while using the app, Allow once ...
If i edit my settings on the phone to have the app location always then it is working. So my question is what should i do so the user has the option to allow always the location
If i stop the app execution from xcode and start the app from my device without monitoring it in xcode the background runner event is not triggered at all, i can see the location icon on my phone that pops up for some seconds but no data is sent to dashboard, when i activate the app then all calls are getting triggered and i am getting 4-5 requests to the dashboard.
I has thinking that CapacitorGeolocation.getCurrentPosition() can't get the location in the 30 seconds so i commented it and added manual location data, but even so the fetch is not getting triggered.
Did you have this problem ? Could somebody help me out please. I am using Ionic 7 with vuejs and capacitor 5
Thank you.
The text was updated successfully, but these errors were encountered:
Hi,
i am trying to make this work for 3 days now, i am sure that is something small but i can't figure it out.
So here we go:
I am using it on iOS, i made my configurations as in the documentation
And now comes the interesting part, if i dispatch the event from the app when it's state is active all is working ok, i am getting the location and it is sent to the dashboard, but when a send the app in background i have 2 strange problems:
If i edit my settings on the phone to have the app location always then it is working.
So my question is what should i do so the user has the option to allow always the location
I has thinking that CapacitorGeolocation.getCurrentPosition() can't get the location in the 30 seconds so i commented it and added manual location data, but even so the fetch is not getting triggered.
Did you have this problem ? Could somebody help me out please. I am using Ionic 7 with vuejs and capacitor 5
Thank you.
The text was updated successfully, but these errors were encountered: