flutter_umeng_push 0.0.7 copy "flutter_umeng_push: ^0.0.7" to clipboard
flutter_umeng_push: ^0.0.7 copied to clipboard

A new Flutter plugin for Android to use umeng push.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_umeng_push/flutter_umeng_push.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final FlutterUmengPush _flutterUmpush = new FlutterUmengPush();

  @override
  void initState() {
    super.initState();
    initPushState();
  }

  Future<void> initPushState() async {
    _flutterUmpush.configure(
      onReceiveMessage: (String message) async{
        print("main onReceiveMessage: $message");
        setState(() {
          _platformVersion = "收到消息:$message";
        });
      },
      onMessage: (String message) async {
        print("main onMessage: $message");
        setState(() {
          _platformVersion = message;
        });
        return true;
      },
      onLaunch: (String message) async {
        print("main onLaunch: $message");
        setState(() {
          _platformVersion = message;
        });
        return true;
      },
      onResume: (String message) async {
        print("main onResume: $message");
        setState(() {
          _platformVersion = message;
        });
        return true;
      },
      onToken: (String token) async {
        print("main onToken: $token");

        setState(() {
          _platformVersion = token;
        });
        return true;
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin for Android to use umeng push.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_umeng_push