loplat_plengi 1.0.8-dev.4
loplat_plengi: ^1.0.8-dev.4 copied to clipboard
loplat plengi(Place Engine) SDK plugin project.
loplat_plengi #
loplat plengi(Place Engine) SDK plugin project.
Supported platforms #
- Flutter Android(plengi v2.1.1.9.6)
- Flutter iOS(MiniPlengi v1.4.2.2)
| Android | iOS | |
|---|---|---|
| Support | SDK 21+ | 9.0+ |
Usage #
To use this plugin, add loplat_plengi as a dependency in your pubspec.yaml file.
Examples #
Here are small examples that show you how to use the API.
Android #
Required Google Play Service library setup
To see detail, please visit loplat developer site.
For efficient location information acquisition, You need to apply the library to the dependencies of build.gradle as follows.
implementation 'com.google.android.gms:play-services-location:21.0.1'
To use loplat X, You need to apply the Google Play Services library to the dependencies of build.gradle as follows.
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
Setup RETROFIT and GSON libraries
Retrofit and GSON libraries are used for communication with the server when requesting location confirmation. To apply Retrofit and GSON libraries, add the following to your project's build.gradle.
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
If you are using Proguard, you need to add the following Proguard configuration
-dontwarn okio.**
-dontwarn javax.annotation.**
# R8 compatibility for GSON, Serialization 관련한 룰보다 반드시 위에 먼저 선언
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
-keep class com.loplat.placeengine.cloud.ResponseMessage** {*;}
-keep, allowobfuscation, allowshrinking interface retrofit2.Call
-keep, allowobfuscation, allowshrinking class retrofit2.Response
Start / Stop Plengi
You can start or stop monitoring user places/store visits. Call start right after the user agrees to the location terms and conditions. To see detail, please visit loplat developer site.
Every time the app starts or logs in, you must call start() after checking whether the user agrees to the location terms and conditions.
import 'package:loplat_plengi/loplat_plengi.dart';
await LoplatPlengiPlugin.start("[client_id]", "[client_secret]");
you must call stop() only when the user denies consent to the location terms and conditions.
await LoplatPlengiPlugin.stop();
Setting to receive campaign(advertisement) notifications
To receive notifications (not FCM) through loplat X, you need to write the following code before agreeing to the marketing notification settings menu and starting plengi.
To see detail location data, please visit loplat developer site.
import 'package:loplat_plengi/loplat_plengi.dart';
// When marketing notification setting is ON
// When using notifications created by the app (creating notifications by referencing Advertisement object)
await LoplatPlengiPlugin.enableAdNetwork(true, false);
// When using notifications created by the SDK
await LoplatPlengiPlugin.enableAdNetwork(true, true);
// When marketing notification setting is OFF
await LoplatPlengiPlugin.enableAdNetwork(false);
Receive location data
To see detail location data, please visit loplat developer site.
- Adding loplat SDK dependencies Add the following code in the top-level build.gradle of your project
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://maven.loplat.com/artifactory/plengi"}
google()
}
}
Add the following code along with the above in the 'build.gradle' of your app
WARNING To ensure the SDK functions correctly, you must use the SDK version specified below.
implementation 'com.loplat:placeengine:2.1.1.9.6'
- Implement PlengiListener in Android native code
import android.util.Log;
import com.google.gson.Gson;
import com.loplat.placeengine.PlengiListener;
import com.loplat.placeengine.PlengiResponse;
public class LoplatPlengiListener implements PlengiListener {
private static final String TAG = LoplatPlengiListener.class.getSimpleName();
@Override
public void listen(PlengiResponse response) {
try {
String jsonStr = new Gson().toJson(response);
Log.d(TAG, jsonStr);
} catch (Exception ignored) {
Log.e(TAG, ignored.toString());
}
}
}
- Call setListener() when MainApplication.onCreate() is called
import io.flutter.app.FlutterApplication;
import android.content.Context;
import com.loplat.placeengine.Plengi;
public class MainApplication extends FlutterApplication {
@Override
public void onCreate() {
super.onCreate();
Context applicationContext = getApplicationContext();
Plengi plengi = Plengi.getInstance(applicationContext);
plengi.setListener(new LoplatPlengiListener());
plengi.setEchoCode("[your_echo_code]");
}
}