sona 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 62

logo

sona makes possible using getui push in flutter.

简介

Sona是个推推送SDK在Flutter上的实现。通过Sona,可以在Flutter上轻松使用个推推送。 使用Sona之前,请到个推官网进行应用注册。

所用到的技术

android使用到了kotlin-1.2.71

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    api 'com.getui:sdk:2.12.5.0'
}

iOS上:

  s.dependency 'GTSDK'
  s.ios.deployment_target = '8.0'

Flutter上:

Flutter 0.9.4 • channel beta • https://github.com/flutter/flutter.git
Framework • revision f37c235c32 (2 weeks ago) • 2018-09-25 17:45:40 -0400
Engine • revision 74625aed32
Tools • Dart 2.1.0-dev.5.0.flutter-a2eb050044

初始化

鉴于AndroidiOS的差异化,对应平台设置还需手动设置,具体请参考官网。 在Flutter中通过Sona初使化个推推送:

    import 'package:sona/sona.dart' as sona;
    sona.register(sona.RegisterGetuiPushModel(
        appID: "your app id",
        appKey: "your app key",
        appSecret: "app secret"
    ));

appIDappKeyappSecret目前仅在iOS上生效,因为在android上,这些配置是在build.gradle中完成的,所以使用Sona之前 一定要在android工程配置appIDappKey以及appSecret

defaultConfig {
        //some configrations

        manifestPlaceholders = [
                GETUI_APP_ID : "APP_ID",
                GETUI_APP_KEY : "APP_KEY",
                GETUI_APP_SECRET : "APP_SECRET"
        ]
    }

接收透传

通过监听receivedMessageData可以获取个推推送的透传数据:

   sona.receivedMessageData.listen((payload){
      //接收到透传
      });

其中payloadMap<dynamic,dynamic>根据平台不台,其包含的key也不同:

  • appID:String
  • taskID:String
  • messageID:String
  • offLine:bool
  • payload:String or null
  • pkgName:String,仅安卓平台

0.0.3

  • 升级android部分所使用的技术
  • 修复在flutter-0.9.7+上的Expected type mismatch

0.0.2

  • 增加了iOS获取clientID。
  • 修复在android注册报错的问题。

0.0.1

  • initial release.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:sona/sona.dart' as sona;

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

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

class _MyAppState extends State<MyApp> {
  String _result = 'Unknown';


  @override
  void initState() {
    super.initState();
    sona.register(sona.RegisterGetuiPushModel(
        appID: "your app id",
        appKey: "your app key",
        appSecret: "app secret"
    )).then((data){
      print(data.runtimeType.toString());
    });
//    sona.receivedMessageData.listen(_receiveData,onError: (error){
//      print("erro ");
//    },onDone: (){
//      print("done");
//    });



  }


  _receiveData(dynamic data){

    setState(() {
      _result = data.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('messge: $_result\n'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sona: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sona/sona.dart';
  
Version Uploaded Documentation Archive
0.0.5 Nov 13, 2018 Go to the documentation of sona 0.0.5 Download sona 0.0.5 archive
0.0.4 Oct 15, 2018 Go to the documentation of sona 0.0.4 Download sona 0.0.4 archive
0.0.3 Oct 12, 2018 Go to the documentation of sona 0.0.3 Download sona 0.0.3 archive
0.0.2 Sep 19, 2018 Go to the documentation of sona 0.0.2 Download sona 0.0.2 archive
0.0.1 Sep 18, 2018 Go to the documentation of sona 0.0.1 Download sona 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8