Xamarin development requires the installation of Microsoft Visual Studio. Information regarding installation for Xamarin development is available for Mac or Windows.
An Apple developer account and the latest version of Xcode (available from the App Store) are required if you are building an iOS app.
Package Manager Installation
The ACPPlaces Xamarin NuGet package for Android or iOS can be added to your project by right clicking the "Packages" folder within the project you are working on then selecting "Manage NuGet Packages". In the window that opens, ensure that your selected source is nuget.org
and search for "Adobe.ACP". After selecting the Xamarin AEP SDK packages that are required, click on the "Add Packages" button. After exiting the "Add Packages" menu, right click the main solution or the "Packages" folder and select "Restore" to ensure the added packages are downloaded.
Manual installation
Local ACPPlaces NuGet packages can be created via the included Makefile. If building for the first time, run:
make setup
followed by:
make release
The created NuGet packages can be found in the bin
directory. This directory can be added as a local nuget source and packages within the directory can be added to a Xamarin project following the steps in the "Package Manager Installation" above.
The ACPPlaces binding can be opened by loading the ACPPlaces.sln with Visual Studio. The following targets are available in the solution:
- Adobe.ACPPlaces.iOS - The ACPPlaces iOS binding.
- Adobe.ACPPlaces.Android - The ACPCore Android binding.
- ACPPlacesTestApp - The Xamarin.Forms base app used by the iOS and Android test apps.
- ACPPlacesTestApp.iOS - The Xamarin.Forms based iOS manual test app.
- ACPPlacesTestApp.Android - The Xamarin.Forms based Android manual test app.
- ACPPlacesiOSUnitTests - iOS unit test app.
- ACPPlacesAndroidUnitTests - Android unit test app.
Before using places You also need to initialize Core for using Places.
iOS:
// Import the SDK
using Com.Adobe.Marketing.Mobile;
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
//{Your App related code}
//Registering Core and Places.
ACPCore.SetWrapperType(ACPMobileWrapperType.Xamarin);
ACPPlaces.RegisterExtension();
ACPCore.ConfigureWithAppID("{your-launch-id}");
ACPCore.Start(null);
//{Your App related code}
}
Android:
// Import the SDK
using Com.Adobe.Marketing.Mobile;
protected override void OnCreate(Bundle savedInstanceState)
{
//{Your App related code}
ACPCore.SetWrapperType(WrapperType.Xamarin);
//Registering Core and Places.
ACPCore.Application = this.Application;
ACPPlaces.RegisterExtension();
ACPCore.Start(null);
ACPCore.ConfigureWithAppID("{your-launch-id}");
//{Your App related code}
}
iOS and Android
ACPPlaces.ExtensionVersion();
Android
ACPPlaces.GetCurrentPointsOfInterests(new AdobeCallback());
class AdobeCallBack : Java.Lang.Object, IAdobeCallback
{
public void Call(Object result)
{
JavaList pointOfInterset = (JavaList) result;
}
}
iOS
Action<NSArray<ACPPlacesPoi>> action = (pois) => {
// Your code.
}
ACPPlaces.GetCurrentPointsOfInterests(action);
Android
Location location = new Location("ACPPlacesTestApp.Xamarin");
//San Jose down town coordinates.
location.Latitude = 37.3309;
location.Longitude = -121.8939;
int count = 10; //Nearby 10 point of interest.
ACPPlaces.GetNearbyPointsOfInterest(location, 10, new AdobeCallback());
class AdobeCallBack : Java.Lang.Object, IAdobeCallback
{
public void Call(Object result)
{
JavaList pointOfInterset = (JavaList) result;
}
}
iOS and
CLLocationCoordinate2D coordinate = new CLLocationCoordinate2D();
coordinate.Latitude = 37.3309;
coordinate.Longitude = -121.8939;
int count = 10; //Nearby 10 point of interest.
Action<NSArray<ACPPlacesPoi>> action = (pois) => {
// Your code.
}
ACPPlaces.GetNearbyPointsOfInterest(coordinate, count, action); //Coordinates of San Jose Downtown.
Android
GeofenceBuilder builder = new GeofenceBuilder();
builder.SetCircularRegion(37.3309, -121.8939, 2000);
builder.SetExpirationDuration(60 * 60 * 100); //one hour
builder.SetRequestId("SanJose Downtown");
builder.SetLoiteringDelay(10000);
builder.SetTransitionTypes(Geofence.GeofenceTransitionEnter);
builder.SetExpirationDuration(50000);
builder.SetNotificationResponsiveness(100);
IGeofence geofence = builder.build();
int transition = 1; //Entry into Geofence
ACPPlaces.ProcessGeofence(geofence, transitionType);
iOS
CLLocationCoordinate2D coordinate = new CLLocationCoordinate2D();
coordinate.Latitude = 37.3309;
coordinate.Longitude = -121.8939;
CLCircularRegion circularRegion = new CLCircularRegion(coordinate, 2000, "ACPPlacesTestApp.xamarin")
ACPRegionEventType regionEventType = ACPRegionEventType.Entry;
ACPPlaces.ProcessRegionEvent(circularRegion, regionEventType);
Android
ACPPlaces.GetLastKnownLocation(new AdobeCallback());
class AdobeCallBack : Java.Lang.Object, IAdobeCallback
{
public void Call(Object result)
{
Location location = (Location) object;
}
}
iOS
Action<CLLocation> action = (location) => {
// Your code.
}
ACPPlaces.GetLastKnownLocation(action);
Android
ACPPlaces.Clear();
iOS
ACPPlaces.Clear();
Android
ACPPlaces.SetAuthorizationStatus(PlacesAuthorizationStatus.always);
iOS
ACPPlaces.SetAuthorizationStatus(CLAuthorizationStatus.Authorized);
iOS and Android unit tests are included within the ACPPlaces binding solution. They must be built from within Visual Studio then manually triggered from the unit test app that is deployed to an iOS or Android device.
A Xamarin Forms sample app is provided in the Xamarin ACPPlaces solution file.
Looking to contribute to this project? Please review our Contributing guidelines prior to opening a pull request.
We look forward to working with you!
This project is licensed under the Apache V2 License. See LICENSE for more information.