cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
265 stars 317 forks source link

Not working in ios 9.2 #110

Closed sunojvijayan closed 8 years ago

sunojvijayan commented 8 years ago

Hi I have successfully installed and tested the app in Android. But when I installed the plugin in IOS 9.2 device, it is not working. Please help. I dont have a device with ios 8 to test.

tsubik commented 8 years ago

I haven't tried this on iOS 9.2 yet. Maybe someone else?

JoergHolz commented 8 years ago

I have just tested it, it works for me with 9.2.

sunojvijayan commented 8 years ago

I am building using "sudo cordova build ios". Then I am using xcode to run the app in the device. Everything is running correctly. But I am not getting any notifications.

sunojvijayan commented 8 years ago

Do I have to enable any permissions or change any settings in xcode. I am using free developer id.

JoergHolz commented 8 years ago

Don't use sudo everywhere, just cordova build. See the docs: http://cordova.apache.org/docs/en/dev/guide/cli/index.html Maybe that is the problem.

sunojvijayan commented 8 years ago

I am not able to build if i dont use sudo

sunojvijayan commented 8 years ago

Plus it works in android

sunojvijayan commented 8 years ago

Ok Here is what I did so far.

I created a new project. Added ios and android platforms. Added the puggin. build for ios and android. run the app in android and its working.

In IOS I am using free developer license. I am using Xcode version 7.2(7c68) Cordova v 5.4.1 I build the project for ios Open the Xcode project in the platforms folder. Ran the app on iphone 6s It runs without any error but geolocation alert is not showing but the same code shows alert in android phone. I checked my phone setting and found that in privacy\notification permission was not given so i changed it to always but still its not working.

Can anyone help please?

JoergHolz commented 8 years ago

Are the notification settings on your device okay? Have you tried geofence in the simulator? In the simulator you can change the location in Debug -> Location.

sunojvijayan commented 8 years ago

I tried running it in simulator and from debug gave the location but no alert is coming there also. Do I have to change any notification settings in the device.

robertken commented 8 years ago

Make sure your app is not open when you do the location change, it took me a bit to realize that. I'm on 9.2 and didn't need to change notification settings (except for accepting the 'allow app to send notification' prompt at the start)

sunojvijayan commented 8 years ago

See thatni think is the problem. When I install and run the app there is no prompt for permission. Why do you think that is

robertken commented 8 years ago

Try uninstalling and re running the app to reset the permissions. Also make sure that where you put the .init is being called. With cordova/js it's sometimes tricky to see if code is actually run or not. I put it in either a try/catch block or put an alert before and after. If i see both alerts, i can reasonably guess that the code in between was actually called, not just skipped because of syntax error

sunojvijayan commented 8 years ago

Hi I have uninstalled the entire app. Created a new app without sudo. Added android and ios platforms. Added the pluggin. Added my code and run the app in android using "cordova run android" it works fine. Then i run "cordova build ios" and then open the project in xcode and run it on the device and emulator it does not work. I was debugging in xcode and found that "addOrUpdate" and "getWatched" works fine but "onTransitionReceived" is not getting called. I did not get any permission popup as well.

sunojvijayan commented 8 years ago

But I am getting this in the console

2016-01-21 17:06:34.563 GeoFence[2847:73675] GeofencePlugin - GeoNotificationManager addOrUpdate 2016-01-21 17:06:34.565 GeoFence[2847:73675] GeofencePlugin - Warning: Location always permissions not granted, have you initialized geofence plugin? 2016-01-21 17:06:34.567 GeoFence[2847:73675] GeofencePlugin - Warning: notification settings - sound permission missing 2016-01-21 17:06:34.568 GeoFence[2847:73675] GeofencePlugin - Warning: notification settings - alert permission missing 2016-01-21 17:06:34.568 GeoFence[2847:73675] GeofencePlugin - Warning: notification settings - badge permission missing 2016-01-21 17:06:34.569 GeoFence[2847:73675] GeofencePlugin -

JoergHolz commented 8 years ago

In your simulator go to Hardware -> Home. Then in the simulator window, open settings and scroll down to your app and click on it and then change the permissions for notifications.

If this does not work, I would make a fresh install of Xcode and the simulators.

sunojvijayan commented 8 years ago

There permission for audio badge and alert are not there

sunojvijayan commented 8 years ago

In settings I am not able to find settings for notification.

sunojvijayan commented 8 years ago

Also when I am installing it is not asking for permission. I am using version 7.2(7c68) and device iphone 6s with ios 9.2

sunojvijayan commented 8 years ago

sorry xcode version 7.2(7c68

sunojvijayan commented 8 years ago

Which version of Xcode are you using?

tsubik commented 8 years ago

Ok. I've tested on iOS 9.2 and it works. Maybe you forgot to initialize plugin?

sunojvijayan commented 8 years ago

How do I initialise pluggin

sunojvijayan commented 8 years ago

And it's working on android. Can u tell me the version of Xcode you used.

JoergHolz commented 8 years ago

Two weeks later ;-)) I remember, that I forgot to initialize the plugin the first time also. Do it this way:

window.geofence.initialize();

tsubik commented 8 years ago

It is in the readme. I just gave you a link in the previous comment, just mind it should be done after Cordova deviceready event. On android device, there is nothing special to happen needed on initialization phase. On iOS, we need to set up those notification permissions, though.

sunojvijayan commented 8 years ago

That worked. Thanks a lot and sorry for wasting your time. 5+ respect to all.

sunojvijayan commented 8 years ago

One last doubt. Will the notification work only when the app is in background? When we completely close the app the notification will not work like in android?

tsubik commented 8 years ago

Great to hear that. If your app is closed you will receive normal local system notification both on android and iOS. Your javascript app code won't work, though.

sunojvijayan commented 8 years ago

I still have a problem. Sorry to disturb you guys. I have the app installed in the device and if i change the location in xcode debugger everything works. But till now I have not received any actual notifications when i move from one place to the next on the actual device.

JoergHolz commented 8 years ago

First: Are you sure, that the app is working?

For getting a higher accuracy of your position, you should enable WiFi and have a device with a sim. If you only use GPS, then your position can vary in a wide range. But this is not an issue of the plugin. I tested this on the canary islands with 8 different devices (iOS and Android) and the plugin is working very well, but the exact position is the problem.

To figure out which service is enabled, you can use this plugin: cordova.plugins.diagnostic

The next point is, that you should not make the radius to small.

sunojvijayan commented 8 years ago

Hi Got it working by increasing the radius. Thanks you once again everyone.

RogerQuiros commented 8 years ago

I had the same issue and the same console log as @sunojvijayan , but i noticed that in my case it was because the plugin tries to initialize before the users accept the required permissions. If I close the app and try again, the plugin runs without problem. My problem now is how I show the permission dialog before get initialize the plugin, for a first time user. Thanks in advance for any help.

RawiaAhmed commented 8 years ago

hi @Rocker506 have you solved your issue?

RogerQuiros commented 8 years ago

Hi, @RawiaAhmed what i did to solved, was to initialize two times in two different part of my application, first on my login screen, and second in the map section of the app. So if the user fails to accept the permission at the login screen, it will prompt a second time on the map screen. Wasn't the most sophisticated way to do it, but using Cordova, I guess that you have to be more creative than sophisticated.

Buddikazz commented 7 years ago

not working on ios with giving radius 30000m initialize working normally but notification not trigured

Spanchal21 commented 6 years ago

same issue notification not trigured. it's working fine with android.