flutterupushplugin 0.0.4
flutterupushplugin: ^0.0.4 copied to clipboard

一个使用u meng push(友盟推送flutter版)的flutter插件。

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutterupushplugin/u_push_plugin.dart';
import 'package:flutterupushplugin/u_push_options.dart';
import 'package:flutterupushplugin_example/test_page.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {

  int index=0;
  GlobalKey key;
  var  mapview1=null;
  UpushPlugin mUpushPlugin = UpushPlugin();
  String result = "返回消息提示";
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    //消息的回调
    mUpushPlugin.addEventHandle(
        onReceiveCustomMessage: (Map<String, dynamic> event) {
          setState(() {
            result = "用户自定义消息内容: ${event} ";
          });
        },
        onReceiveNotification: (Map<String, dynamic> event) {


          setState(() {
            result ="在线接收通知"+ event.toString();
          });
        },
        onReceiveOffLineNotification: (Map<String, dynamic> event) {
          setState(() {
            result = "离线通知:"+event.toString();
          });
        });

  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(

        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body:Center(
          child: Column(
            children: <Widget>[
              Text("返回结果:" + result),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.addTags(["tags1", "tags2"]).then((value) {
                    debugPrint(" 添加标签 ${value} ");
                    setState(() {
                      result = " 添加标签  结果:${value} ";
                    });
                  });
                },
                child: Text("添加标签   tags1, tags2"),
              ),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.deleteTags(["tags1", "tags2"]).then((value) {
                    debugPrint(" 删除标签 结果:${value} ");
                    setState(() {
                      result = " 删除标签 结果:${value} ";
                    });
                  });
                },
                child: Text("删除标签  tags1, tags2"),
              ),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.getTags().then((value) {
                    debugPrint(" 获取标签  结果:${value} ");
                    setState(() {
                      result = " 获取标签 结果:${value} ";
                    });
                  });
                },
                child: Text("获取标签"),
              ),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.addAlias("flutter","android").then((value) {
                    debugPrint(" 添加别名  结果:${value} ");
                    setState(() {
                      result = " 添加别名 结果:${value} ";
                    });
                  });
                },
                child: Text("同时添加别名 flutter,android"),
              ),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.setAlias("flutter","ios").then((value) {
                    debugPrint(" 设置别名  结果:${value} ");
                    setState(() {
                      result = " 设置别名  结果:${value} ";
                    });
                  });
                },
                child: Text("同时设置别名 flutter,ios"),
              ),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.deleteAlias("flutter","ios").then((value) {
                    debugPrint(" 删除别名 结果:${value} ");
                    setState(() {
                      result = " 删除别名 结果:${value} ";
                    });
                  });
                },
                child: Text("同时删除别名 flutter,ios "),
              ),
              RaisedButton(
                onPressed: () {
                  mUpushPlugin.getRegistrationId().then((value) {
                    debugPrint(" 获取注册id ${value} ");
                    setState(() {
                      result = " 获取注册id ${value} ";
                    });
                  });
                },
                child: Text("获取注册id "),
              ),
            ],
          ),
        )


        ,
      ));
  }
}
2
likes
70
pub points
11%
popularity

一个使用u meng push(友盟推送flutter版)的flutter插件。

Homepage

Documentation

API reference

Uploader

wsl900328@gmail.com

License

LICENSE

Dependencies

flutter

More

Packages that depend on flutterupushplugin