Place Attachment On-Demand
Overview
There are some cases where you may want to know where the user is regardless of whether or not they are moving. For example, if your user is trying to check-in to a POI and you want to use our SDK to populate the candidates for the check-in UI. We have a genPlaceCandidatesWithDelegate
method for that.
Getting Place Candidates
To set up your app to receive on-demand place attachment responses, first have your AppDelegate
implement the FactualPlacesDelegate
protocol:
#import <UIKit/UIKit.h>
#import "FactualEngine.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate,
FactualEngineDelegate, // Engine system debug info
FactualPlacesDelegate> // handling place candidates
@property (strong, nonatomic) UIWindow *window;
@end
// ---- methods to support the FactualPlacesDelegate interface ----
- (void)placeCandidatesDidGenerate:(PlaceCandidateResponse *)candidates{
NSLog(@"Engine Candidates returned: %@", [candidates toDict]);
}
- (void)placeCandidatesDidFailWithError:(FactualError *)error{
NSLog(@"Engine Place Candidate error: %@", [error message]);
}
Then, you can asynchronously request an on-demand place attachment at some point after Engine has started. For example, in the engineDidStartWithInstance
callback:
// ---- methods to support the FactualEngineDelegate interface ----
- (void)engineDidStartWithInstance:(FactualEngine *)engine {
NSLog(@"Engine started.");
// Example of getting a list of candidates for my current location.
[engine genPlaceCandidatesWithDelegate:self]; // FactualPlacesDelegate
}
Refer to our iOS Class List for more information on the PlaceCandidateResponse
returned in the placeCandidatesDidGenerate
callback.
Updated about 3 years ago