Giter VIP home page Giter VIP logo

flutter_gt_plugin's Introduction

flutter_gt_plugin

个推iOS、Android插件 目前功能 通知、透传消息以及获取clientId

Getting Started

在工程 pubspec.yaml 中加入 dependencies flutter_gt_plugin: git: https://github.com/shinenyok/flutter_gt_plugin.git

配置

iOS:

  • 在 xcode8 之后需要点开推送选项: TARGETS -> Capabilities -> Push Notification 设为 on 状态

Android

  • 注册app成功以后分别拿到appId、appKey、appSecret,在android/app目录下的build.gradle 文件中配置如下代码
        manifestPlaceholders = [
                GETUI_APP_ID    : "appId",
                GETUI_APP_KEY   : "appKey",
                GETUI_APP_SECRET: "appSecret",
        ]

使用

import 'package:flutter_gt_plugin/flutter_gt_plugin.dart';

注意:addEventHandler 方法建议放到 setup 之前,其他方法需要在 setup 方法之后调用

addEventHandler

添加事件监听方法。

dart
FlutterGtPlugin.addEventHandler(
    //接收clientId回调方法
    getClientId: (Map<String, dynamic> message) async {
       print("flutter getClientId: ${message['clientId']}");
     }, 
     //点击通知回调方法
     onOpenNotification: (Map<String, dynamic> message) async {
       print("flutter onOpenNotification: $message");
     });

setup

添加初始化方法,调用setup方法会执行两个操作

  • 初始化个推SDK
  • 将缓存事件下发到dart环境中
dart
FlutterGtPlugin.setup(
        appId: '替换成自己的 appId',
        appKey: '替换成自己的 appKey',
        appSecret: '替换成自己的 appSecret');

applyPushAuthority

申请推送权限,注意这个方法只会向用户弹出一次推送权限请求(如果用户不同意,之后只能用户到设置页面里面勾选相应权限),需要开发者选择合适的时机调用。

dart
    FlutterGtPlugin.applyPushAuthority();

flutter_gt_plugin's People

Contributors

shinenyok avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.