Note: The following document description shall prevail, do not refer to the settings in the example
Usages
Import
dependencies:
umeng_analytics_push: ^x.x.x #The latest version is shown above, plugin1.x supports flutter1.x, plugin2.x supports flutter2.x# Or import through Git (choose one, Git version may be updated more timely)dependencies:
umeng_analytics_push:
git:
url: https://github.com/zileyuan/umeng_analytics_push.git
Android settings (with Kotlin example)
Create a custom FlutterApplication class as the startup class, if the push function is not needed, uemng_message_secret is set to empty
packagecom.demo.umeng.appimportandroid.os.Handlerimportandroid.os.Looperimportandroid.content.Intentimportandroidx.annotation.NonNull;importio.flutter.embedding.android.FlutterActivityimportio.flutter.embedding.engine.FlutterEngineimportio.flutter.plugins.GeneratedPluginRegistrantimportio.github.zileyuan.umeng_analytics_push.UmengAnalyticsPushFlutterAndroidimportio.github.zileyuan.umeng_analytics_push.UmengAnalyticsPushPluginclassMainActivity: FlutterActivity() {
var handler:Handler=Handler(Looper.myLooper())
overridefunconfigureFlutterEngine(@NonNull flutterEngine:FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
overridefunonNewIntent(intent:Intent) {
// Actively update and save the intent every time you go back to the front desk, and then you can get the latest intent
setIntent(intent);
super.onNewIntent(intent);
}
overridefunonResume() {
super.onResume()
UmengAnalyticsPushFlutterAndroid.androidOnResume(this)
if (getIntent().getExtras() !=null) {
var message = getIntent().getExtras().getString("message")
if (message !=null&& message !="") {
// To start the interface, wait for the engine to load, and send it to the interface with a delay of 5 seconds
handler.postDelayed(object:Runnable {
overridefunrun() {
UmengAnalyticsPushPlugin.eventSink.success(message)
}
}, 5000)
}
}
}
overridefunonPause() {
super.onPause()
UmengAnalyticsPushFlutterAndroid.androidOnPause(this)
}
}