To use the Places Monitor extension, complete the following tasks:
There are no configuration tasks for the Places Monitor extension.
Directions on adding the Places Monitor extension to your Android or iOS application is below.
Additional platform support for the Places Monitor extension include:
Cordova Places Monitor
In Android, complete the following steps:
Add the Places Monitor extension and the Places extension to your project using your app’s gradle file.
Also include the latest Google Location services in the gradle file.
implementation 'com.adobe.marketing.mobile:places:1.+'
implementation 'com.adobe.marketing.mobile:places-monitor:1.+'
implementation 'com.adobe.marketing.mobile:sdk-core:1.+'
implementation 'com.google.android.gms:play-services-location:16.0.0'
Import the Places Monitor extension in your application’s main activity.
import com.adobe.marketing.mobile.PlacesMonitor;
In iOS, complete the following steps:
Podfile
by adding pod 'ACPPlacesMonitor'
.#import "ACPCore.h"
#import "ACPPlaces.h"
#import "ACPPlacesMonitor.h"
import ACPCore
import ACPPlaces
import ACPPlacesMonitor
You need to register and start the Places Monitor in Android or iOS.
In Android, complete the following steps:
In your App’s OnCreate
method register the Places Monitor extensions:
public class MobileApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
MobileCore.ConfigureWithAppId("yourAppId");
try {
PlacesMonitor.registerExtension(); //Register PlacesMonitor with Mobile Core
Places.registerExtension(); //Register Places with Mobile Core
MobileCore.start(null);
PlacesMonitor.start();//Start monitoring the geo-fences
} catch (Exception e) {
//Log the exception
}
}
}
Places monitoring depends on the Places extension. When you manually install the Places Monitor extension, ensure that you also add the places.aar
library to your project.
In your iOS app’sapplication:didFinishLaunchingWithOptions
, register PlacesMonitor
and Places with Mobile Core:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
[ACPCore configureWithAppId:@"yourAppId"];
[ACPPlaces registerExtension];
[ACPPlacesMonitor registerExtension];
[ACPCore start:^{
// do other initialization required for the SDK
[ACPPlacesMonitor start];
}];
return YES;
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ACPCore.configure(withAppId: "yourAppId")
ACPPlaces.registerExtension()
ACPPlacesMonitor.registerExtension()
ACPCore.start({
// do other initialization required for the SDK
ACPPlacesMonitor.start()
})
// Override point for customization after application launch.
return true
}
Places monitoring depends on the Places extension. When manually installing the Places Monitor extension, ensure that you also add the libACPPlaces_iOS.a
library to your project.
Java
For all versions of Android, to declare that your app needs location permission, add a <uses-permission>
element in your app manifest, as a child of the top-level <manifest>
element. For Android applications that target API Level 29 and above, to allow the app to access location in background, include the ACCESS_BACKGROUND_LOCATION permission.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.adobe.placesapp">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
// Only for Android apps targeting API level 29 and above
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<application>
...
</application>
</manifest>
iOS supports the delivery of location events to apps that are suspended or no longer running. To receive location updates in the background for the Places Monitor extension, configure the Location updates capability for your app in Xcode.background-location-updates
.
The following keys must be included in your app’s Info.plist
file:
NSLocationWhenInUseUsageDescription
- the text should describe why the app is requesting access to the user’s location information while running in the foreground.NSLocationAlwaysAndWhenInUseUsageDescription
- the text should describe why the app is requesting access to the user’s location information at all times.If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription
key is also required.