To integrate PoilabsNavigation into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'PoilabsAnalysis'
You can add PoilabsAnalysis.xcframework file to your "Frameworks, Libaries, and Embedded Content" in your Project’s General Tab.
To Integrate this framework you should add some features to your project info.plist file.
This framework give support both Always and WhenInUse authorization.
-
Privacy - Location Usage Description
-
Privacy - Location When In Use Usage Description
-
Privacy - Location Always Usage Description
-
Privacy - Location Always and When In Use Usage Description
You should add "Location updates" and "Uses Bluetooth LE accessories" Background Modes from Project's Signing & Capabilities tab.
You should import framework in your AppDelegate
import PoilabsAnalysis
In applicationDidBecomeActive: method you should activate the framework:
PLAnalysisSettings.sharedInstance().applicationId = APPLICATION_ID
PLAnalysisSettings.sharedInstance().applicationSecret = APPLICATION_SECRET_KEY
PLAnalysisSettings.sharedInstance().analysisUniqueIdentifier = UNIQUE_ID
PLConfigManager.sharedInstance().getReadyForTracking(completionHandler: { error in
if error != nil {
if let anError = error {
print("Error Desc \(anError)")
}
} else {
print("Error Nil")
PLSuspendedAnalysisManager.sharedInstance()?.stopBeaconMonitoring()
PLStandardAnalysisManager.sharedInstance()?.startBeaconMonitoring()
PLStandardAnalysisManager.sharedInstance().delegate = self as? PLAnalysisManagerDelegate
}
})
In didFinishLaunchingWithOptions: method you should activate the framework:
if launchOptions?[UIApplication.LaunchOptionsKey.location] != nil {
if application.applicationState == UIApplication.State.background {
PLSuspendedAnalysisManager.sharedInstance()?.startBeaconMonitoring()
}
}
If you want to close all location services and regions for SDK you can call this method:
PLAnalysisSettings.sharedInstance()?.closeAllActions()
You can only test PoilabsAnalysis sdk with real device. You can run on simulator but for testing you should run on a iPhone.
Some test cases are only for versions 3.8.2 or above. For better test cases, please update PoilabsAnalysis if you integrated a lower version.
Error of below method should be nil.
PLConfigManager.sharedInstance().getReadyForTracking(completionHandler: { error in
})
- Request failed: forbidden (403)
- Please check APPLICATION ID and APPLICATION SECRET KEY
- Your Application id is Unavailable
- Set PLAnalysisSettings.sharedInstance().applicationId
- Your Application secret is Unavailable
- Set PLAnalysisSettings.sharedInstance().applicationSecret
- Your Analysis uniqueId is Unavailable
- Set PLAnalysisSettings.sharedInstance().analysisUniqueIdentifier
Foreground monitoring means scaning beacon and returning relevant node's id when application is active. If you initilize PoilabsAnalysis sdk with nil error and start beacon monitoring of PLStandartAnalysisManager, node ids will return to callback below.
extension AppDelegate: PLAnalysisManagerDelegate {
func analysisManagerResponse(forBeaconMonitoring response: [AnyHashable : Any]!) {
print(response)
}
}
For getting response, you have to be nearby of a beacon with data which are shared by PoiLabs.
Trigger of this callback can take time, please wait for minumun 30 seconds after start monitoring.
You can see an example of response below.
{
"data": [
["nodeid1", "nodeid2", ...],
["nodeid1", ...],
["nodeid1", ...],
...
],
"status": 1
}
If you can get a reponse like this, foreground monitoring is successfully integrated.
Background monitoring means scaning beacon when application is killed.
Before start to test please make sure always location permission is given.
To activate background mode, you should kill application and lock the screen. After you show the lock screen or unlock your iPhone, background monitoring will start if you entegrate it, like in the section USAGE/For background tracking.
For getting response, you have to be nearby of a beacon with data which are shared by PoiLabs.
You can test background monitoring on Console. Open Console application on your Mac. Type PLAnalysisSdk to search field. Select your iPhone from Devices section on the left. Press start button.
First you will see start log and then if sdk find any beacon and get its id, you will see response log. Examples of logs are below.
PLAnalysisSdk <PLSuspendedAnalysisManager: 0x...>->SuspendedAnalysisManager startBeaconMonitoring
PLAnalysisSdk <PLSuspendedAnalysisManager: 0x...>->Response {
data = ( ( "nodeid1", "nodeid2", ... ),
( "nodeid1", ... ),
( "nodeid1", ... )
);
status = 1;
}
If you get these log, background monitoring is successfully integrated.