How to notify when location change in iPhone? - iphone

I am using CLLocationManager class find the current location.When app in background, I want to notify the user while location change using LocalPushnotification, How to set it?

Look at this Question to get the current location when user is in background.
After you get the location send it to your server.
Process the data on the server and create you push notification and send it to apple server.
Good luck

Related

Call status change web-service when my App is deleted

In my application , i works with web-services and when user log in into my app my app is sending a request with status 1 means loged in and when on log out button click sending a request with status 0.
Now problem is , when user removes app from devices , status in my server is remain 1(log in) , hence other user can see him available while his app is not in device. so is there any way by which i can send request when my app removes from device (i don't think it is possible) or is there any other way that i can do in my backend side ?
Thanks in advance.
It is not possible to call a web service when the user deleting the app from an ios device. There are three methods to came to know that whether your application is there in user's ios device. But there are few limitations also.
Activate Push notification: By doing this, device will get registered with Apple's push notification service. When user delete the app from device, the registration will be revoked from APNS server and through the APNS feedback service, you can get to know whether the application is existing. (Limitation: If the user did not agree with receiving push notifications, then the app will not be registered with APNS and you never came to know that whether application is existing or not)
Activate Location Based service: If your application enables location based service, then your application will get periodic location updates in a location delegate method. In this delegate, you can call a webservice and keep update the status of user even the application is in background. (Limitation: If user disables the location update, then your server will not get info about user status)
Periodically Call a Webservice From you app: This is possible only if your app is active. (Limitation: When you application pushed in to background, your application will be in suspended mode, so it will not possible to call webservice)
Sorry Unfortunately Apple not provide any method that user Uninstall app from user's device, There is no such method.
When user delete any application device does give the alert "Do you want to delete this application" with option "Delete" and "Cancel". You don't have to write any specific code for this.
I just assume that There is one method in which you can find out when user is about to delete your app. That is you need to implement push notification Apple server will inform you when you try to push to an uninstalled instance. Other than that there's no way to detect it but i am not sure its helpful or not.
You can't do this from within the app. You would want to do something like have a periodic task which runs on the backend, checking the last activity date of logged in users and setting them to 'not available' after some configured period of inactivity. This will probably require some changes to the backend to record last activity date and a change to the app so that while it's open it sends a periodic 'heartbeat' to the backend. You probably want to make the timeout quite big (say 15 minutes, big enough to not have a large impact on performance).

Fetching data while app in background state

I want the following to implement in my app:
mobile app has to download a list of locations periodically [web service] , in background [even if the application is not running] .
Have to compare the user's current location with those downloaded locations each time.[in background]
Have to alert the user if he is near that location.[push notification]
Can we implement these things [is it possible to call webservice in background]while app is not active ? I have searched a lot and now assuming that calling webservice while app is not in active state is not possible. Kindly confirm.
You can do the 3 task i.e to alert the user using push notification.
As in the inactive state, your app can only receive push notification.
You cannot call a webService.
1: it is impossible to do action if the app is not running
2: it is possible, you can find example for this purpose from iOS SDK document library
3: the app have to running and detect current location real time... when near POI then notify user, about APNS, the same way... the app have to post the current location to back end web server, the web server need detect whether near POI, if yes... send notification via APNS...
hope above helpfully

Managing absence of current location

I am new to the objective C programming and I am in a position where I need to create an iPhone App really quickly. I am using XCode 4.2
I have found a method to get the user country (using NSLocale)
I assume that the application will ask the user if he wants to use his/her current location for that?
if the user says "don t allow" how can we manage that , what are the functions that can be used ?
Thanks
The Core Location methods automatically handles user permission, if that's what you're asking. If the user says he doesn't want his location to be used, well, handle it the way you want : display an error message, of it is crucial to your app, display an alert saying how location is crucial to your app, and exit it. Or something else, it's up to you.
You can check if the location services are enabled system-wise with [CLLocationManager locationServicesEnabled]. For your app only, when getting the location fails, the - locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error message is sent to the location managed delegate. You can check the error domain/code to have more details

Check user location before they see Push Notification Message?

Would someone happen to know a small code sniplet to get and compare the users location before they see a push message inside the appDelegate class?
If the app isn't running, then you can't 'get in the way' the message will be displayed to the user. And where I say running I mean in the foreground and with the screen on.
If the app is running, then you can embed arbitrary information (such as a relevant location) with the push notification payload. When this is delivered to your app's delegate, you can check for their location as you normally would, and if the user is where you'd like them to be you can pop up a message to them.
It seems like a lot of hard work for people that are actually using the app at the time that the notification is delivered though. What will you do about all the users who aren't running the app and get the push notification popup without the check?

Availability of Push notification service in this situation?

i'm working on a football application. the application connects to a webservice and gets the required data via soap request whenever a tab is opened. one of the tab shows live matches of the current day. when the live tab is opened, it refreshes the view by a timer and shows the status updates (goal scored, half time or full time). what i need to do is getting the status updates when the app is closed. the user will select max 2 competitions from settings of the app. then the status updates about these 2 competitions needed to be alerted. can i use push notification service to send soap requests and make alerts according to the response? or does it only allow getting response? or is there anyway that i can do it?
thanx in advance.
I'm not entirely clear what you are asking. The part where you write:
can i use push notification service to send soap
requests and make alerts according to the response?
or does it only allow getting response?
isn't really clear to me. What response are you talking about?
In any case.. push notification is what is says. It pushes a notification to the iPhone.
It does not:
activate your application in the background
allow for any action of your application without the user opening said application first
allow any kind of data to be gather from the phone
If you want the user's phone to talk to your server, the user will need to open your application. If that's what you're asking.