Documentation
Search…
Integration
Connect the app's miles® SDK to all of your app's features to start driving your users and build retention.
Xamarin Integration
Work In Progress
🚩
You have the app's miles banner up and running.
Now you need to integrate the SDK deeper into your application so that your user can: -
🧠
understand how the program works. -
🔎
discover all the functionalities that you slaved away at developing ! -
🥕
be rewarded for consistently using your application's main features.

I. Connection

1. Onboarding

Skip to the Connect section if you intend to have everyone participate in the program by default

Purpose

The first thing that the user will see when clicking on the app's miles banner is the onboarding.
This onboarding has two purposes:
    🎓
    Present and explain the program
    Ask the user their consent to take part in the program

Onboarding choices

There are up to 3 buttons on the onboarding, and you must attach a listener in order to redirect the user depending on their input.
The input of the user will affect the variable OPT_IN in the following way: (default: APM_DEVICE_OPT_IN_NOT_SET)
    👍
    OK: APM_DEVICE_OPT_IN_ACCEPT
    Later: APM_DEVICE_OPT_IN_NOT_SET
    👎
    Never: APM_DEVICE_OPT_IN_REFUSE

Example with MainPage

1
public partial class MainPage : ContentPage
2
{
3
//Declare a object of APMOnboardingUtils in your class
4
private APMOnboardingUtils mOnboardingUtils;
5
6
public MainPage()
7
{
8
InitializeComponent();
9
APM.RefreshSDK();
10
mOnboardingUtils = new APMOnboardingUtils(delegate () {
11
12
Debug.WriteLine("APMOnboardingUtils.OK");
13
14
// User clicked "OK" -> "I want to participate".
15
// TODO: If user not connected, redirect to login/create-account page.
16
// Nothing to do if user connected
17
if (clientAccountConnected) //TODO: check if account client is connected
18
{
19
//Account client is connected
20
Dictionary<string, object> user = APM.GetUser();
21
if (user != null && user["userToken"] != null && !user["userToken"].Equals(""))
22
{
23
//Client account connected and app's miles account connected
24
Debug.WriteLine("Client account connected and app's miles account connected");
25
}
26
else
27
{
28
//Client account connected --> need to connect app's miles account
29
Debug.WriteLine("Client account connected --> need to connect app's miles account");
30
//ApmConnection();
31
}
32
}
33
else
34
{
35
//TODO: show screen login/create account
36
}
37
38
39
}, delegate () {
40
Debug.WriteLine("APMOnboardingUtils.Later");
41
// User clicked "Later" -> "I'll decide later".
42
// The SDK will continue showing the onboarding when clicking the banner
43
// Nothing to do here in general
44
}, delegate () {
45
Debug.WriteLine("APMOnboardingUtils.Never");
46
// User clicked "Never" => "Stop asking me, hide the banner"
47
// Note: The user may change his mind, and it is recommended to have a button
48
// that allows the user to get back in the program
49
// TODO: (Optional) You can redirect to the page with that "Get back in the program" button
50
// (with a little message saying "You can always change your mind by clicking this button")
51
});
52
53
//Listen events of onboarding
54
mOnboardingUtils.RegisterNotifications();
55
}
56
}
Copied!
Call unregister when the screen is in pause:
1
//Unlisten events of onboarding
2
mOnboardingUtils.unregister(this);
Copied!

2. Connect

In order to offer a seamless experience, app's miles doesn't have a login or create-account page. The login/create-account process for app's miles is parallel to yours.

APMUIServicesUser.UserClientConnect()

This method can both connect and create an account:
    If an app's miles account already exists with the given userID, the method signs them in.
    If no account exists, the method will automatically create their account and sign them in.
This method needs : « email », « userID » and « optIn » « email » is the email of user « userID » is a unique identifier in your database – « optIn » is the RGPD OptIn
If you don’t want give the email, you can build a encrypted email with the userID: {userID}@{your-company-name}.com (e.g. [email protected])
1
string userID = "demo-test";
2
string email = partnerClientId + "@demo.com";
3
int optIn = APMServicesConfig.APM_DEVICE_OPT_IN_ACCEPT();
4
APMUIServicesUser.UserClientConnect(email, userID, optIn, delegate (Dictionary<string, Object> user) {
5
Debug.WriteLine("user.email : " + user["email"]);
6
}, delegate (Dictionary<string, Object> error) {
7
Debug.WriteLine("error.errorCode : " + error["errorCode"]);
8
Debug.WriteLine("error.errorMsg : " + error["errorMsg"]);
9
});
Copied!

3. Logout

The same way the login process is parallel to yours, so is the logout.

II. Tagging plan

1. Send an action

In order to reward the user for an action, you need to place triggers in your application. You will need to follow the Tagging plan that your marketing team created with us.
Be careful with the spelling, an extra character like a 's' will change the tag
Call the method triggerAction to send a tag
1
APM.TriggerAction("challenge1"); //challenge1 → actionName
Copied!
Make sure to test each action by looking at the logs, especially for actions that are complex
Earn animation

2. Actions with properties

3. User properties

III. Advanced functions

1. Show/Hide badge

If you want to hide the badge on some screens
1
APM.HideBadge();
Copied!
Don’t forget to re-show badge after hiding
1
APM.ShowBadge();
Copied!
Day ... Night ...

2. Activate debug logs

3. User listener

Last modified 2yr ago