PRXTriggersManager Protocol Reference
Conforms to | NSObject |
Declared in | PRXTriggers.h |
Overview
The PRXTriggersManager protocol is adopted by the shared triggers manager.
Responding to trigger detections in the background
When a trigger is detected while your application is closed, iOS will launch your application in the background to give it an opportunity to respond to the trigger. To do this, ensure that startMonitoring is called before the end of application:didfinishlaunchingWithOptions: so that a notification can be posted, and respond appropriately to the notification.
Ideally, your application should check why it was launched in the background by examining the options passed to -application:didFinishLaunchingWithOptions: and look for the UIApplicationLaunchOptionsLocationKey, which means that the application was launched in response to a location event.
Instance Methods
startMonitoring
Starts monitoring for triggers.
- (void)startMonitoring
Discussion
This method does not guarantee that triggers will actually be detected, as this depends on many external factors depending on the type of trigger, including:
- the application already being authenticated,
- the device having required hardware (e.g. BLE),
- services being enabled on the handset (e.g. Bluetooth), and
- location services being authorized by the user.
It is your responsibility to ensure that these conditions are met. You should prompt the user to
authorise the use of location services and provide a value for the key
NSLocationAlwaysUsageDescription
in your application’s info plist. The value of this key
appears in the permission dialog, and should explain to the user why the app needs access
to their location. Ideally, applications should provide some information in advance about
why the application requires the user’s location.
If monitoring becomes interrupted (for example, bluetooth is turned off temporarily) then as long as this method has been called at some point in the lifetime of the application, monitoring will be resumed.
Declared In
PRXTriggers.h