Notification on CoreLocation

Discussion in 'iOS Programming' started by jnoxx, Aug 26, 2011.

  1. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #1
    Hey guys,

    I have another question.
    Let's say you have an app open, (or in the background), can you check your location like every 20 seconds. And if that is near any point near, can I send a local Notification to the device itself (I don't have alot of experience with Push Notifications/Notifications).
    Second of all, Push Notifications, anyone has any experience with this?
    I would really like to get some infos on that.
    Appreciate it, if you give me something back (by replying) for everything I try to give to the community ;)
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Let's ignore the background bit for now: only a small subset of application types are allowed to run in the background and whilst one is "navigation" what you describe is not really a navigation app so I don't know if it would get approved or not.

    If you look at the CLLocationManager documentation you will see that you don't normally use it in the way you are describing, that is polling every X seconds. Rather you will be notified when the users location has changed (how much it has to change is rather up to you, you can basically be notified continuously of their location if you set the accuracy to be quite precise or just ask to be notified on significant changes in location).

    Once you have the users location you check how near it is to some pre-defined point yourself. The CLLocation object the location manager gives you has a handy distanceFromLocation: method.

    At that point I suppose you could easily send a local notification. It's not clear how or why you would send a push notification: these have to come from a server you own and control and therefore the app would have to talk to that server to send the push notification which would then get sent back to the phone. Unless you want to notify on other devices (say when they get close to each other) local notifications seem to be the correct choice.
     
  3. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #3
    See also the section "Using Regions to Monitor Boundary Crossings" in CLLocationManager documentation. Good luck :)
     
  4. jnoxx thread starter macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    Thanks for the responds.
    For Robbie, I already made an app where I won a price with on the SAP World Tour. Which included polling every x seconds information from a backend, to communicate between 2 clients and show the real life info on the MapKit.
    I know how the MapKit works rather, the problem is actually the background thing.
    for Eg, an customer closes your app with a hard-kill.
    Is it on the iPhone still possible to get the location send to the app, or is it on the iPhone only possible to send the location to a backend, and then use Push Notification?
    I'm just throwing out what I think it is. Because it ain't that easy I have figured out to get a good set up or clear info on that.
    On Android it's possible, that's whats bothering me, because iOS > Android x)

    Gz. Noxx
     
  5. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #5
    For background execution, read this: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html.

    Regarding "hard-kill", the above document mentions the following.

    However that statement is about significant location changes, and it sounds like you want more detail than that. An App configured to receive background location updates does not re-launch after termination.
     
  6. jnoxx thread starter macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #6
    Hmm, thanks for answering to that, i'm very interested in researching everything around this matter.
    Let's say, You restart your phone, your apps are still in the multitask bar, but are closed. Will it ever boot up the app then. I did some tests, and I couldn't get it to work though :(
     
  7. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #7
    Think of that bar as a launcher only. It shows recently used Apps, but provides no information about the background/foreground state of an App.

    Using the significant location service? Or regular background location updates?
     
  8. jnoxx thread starter macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #8

    Regular Location Updates.
    I made one, that checks around the clock, even if it's backgrounded, due to the trick in the .plist. but if you reboot your phone, it will not send these messages.
    So I think there is the problem. You are saying, if I check within my app, and use the significant location service, close my phone. and reboot it, and i change the cellular mast, it should work?
     

Share This Page