0

Is it possible with the new UserNotifications in iOS 10 to discern the difference of entering or exiting a region so that a different notification can be sent?

I have been doing this with CLLocationManager which has didEnter, and didExit delegate methods, but I see no such in the new location trigger.

Is it possible?

jimijon
  • 2,046
  • 1
  • 20
  • 39

1 Answers1

0

Yes, according to the docs on UNLocationNotificationTrigger:

Always use the init(region:repeats:) method to create instances of this class. When configuring the region, use the notifyOnEntry and notifyOnExit properties to specify whether you want notifications to be delivered on entry, on exit, or both.

See the full documentation here: https://developer.apple.com/reference/usernotifications/unlocationnotificationtrigger

Jerry
  • 4,382
  • 2
  • 35
  • 29
  • But if I set a region with "both" then how do I differentiate to show a custom message? – jimijon Nov 15 '16 at 17:20
  • I think you could create different content and different triggers, one with notifyOnEntry and one with notifyOnExit, but with the same region. Then schedule both requests. – Jerry Nov 15 '16 at 19:37
  • The location Trigger takes a region. And there lies the rub. – jimijon Nov 16 '16 at 16:32
  • I don't understand. What is the problem with it taking a region? – Jerry Nov 16 '16 at 18:49
  • since it has a region, and the notifyOnExit and notifyOnEntry are part of the same region, it triggers the alert. But now, how do I tie my message to which one fired? – jimijon Nov 17 '16 at 20:06
  • Can't you create one region with notifyOnEntry and another one with notifyOnExit, but with the same location information? – Jerry Nov 17 '16 at 20:09
  • I could. But that creates another set of overhead refactoring my forms, etc., I just went back to CoreLocation as it has the delegate methods that fire. – jimijon Nov 17 '16 at 20:10