tencent_tpns_oppo_push_plugin 0.0.2 copy "tencent_tpns_oppo_push_plugin: ^0.0.2" to clipboard
tencent_tpns_oppo_push_plugin: ^0.0.2 copied to clipboard

集成腾讯TPNS的OPPO推送

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:tencent_tpns_oppo_push_plugin/tencent_tpns_oppo_push_plugin.dart';
import 'package:tencent_tpns_oppo_push_plugin/enum/importance.dart';

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

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

class _MyAppState extends State<MyApp> {
  List<Map<String, dynamic>> list = new List();
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  callback(data) {
    print("参会了数据");
    Map<String, dynamic> m = new Map();
    m.addAll({
      "name": data['name'],
      "responseCode": data['responseCode'],
      "data": data['data'],
    });
    print(data['name']);
    print(data['responseCode']);
    print(data['data']);
    setState(() {
      list.add(m);
      list = list;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // Platform messages may fail, so we use a try/catch PlatformException.

    TencentTpnsOppoPushPlugin.init(needLog: true);
    TencentTpnsOppoPushPlugin.setCallback(callback: callback);
    bool isSupport = await TencentTpnsOppoPushPlugin.isSupportPush();
    print("isSupport $isSupport");
    TencentTpnsOppoPushPlugin.register(
      appKey: "cf080880fc9747cf8f09baa6d806fb85",
      appSecret: "75bb981450bc4753b93b1978fd014c95",
    );
    TencentTpnsOppoPushPlugin.createNotificationChannel(
      channel: "tuikit",
      name: "test",
      description: "test descrription",
      importance: Importance.IMPORTANCE_DEFAULT,
    );
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: list
                .map((e) => Column(
                      children: [
                        Text("name ${e["name"]}"),
                        Text("responseCode ${e["responseCode"]}"),
                        Text("data ${e["data"].toString()}"),
                      ],
                    ))
                .toList(),
          ),
        ),
      ),
    );
  }
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

集成腾讯TPNS的OPPO推送

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on tencent_tpns_oppo_push_plugin