sona 0.0.9+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

logo pub package

sona makes possible using getui push in flutter.

简介 #

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

初始化 #

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

    import 'package:sona/sona.dart' as sona;
    sona.register(
        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.9+2 #

  • 支持setBadge(仅iOS)。

0.0.9+1 #

  • fix #10

0.0.9 #

  • 增加对onNotificationMessageArrived的监听。

0.0.8 #

  • 增加点击通知栏动作(仅Android)。

0.0.7 #

  • 隐藏RegisterGetuiPushModel。

0.0.6 #

  • kotlin升级至1.3.11。
  • 部分api调整。
  • Android部分SDK升级到2.13.0.0。

0.0.5 #

  • 修复android自定义权限问题(#9)。
  • 升级kotlin至1.3.0

0.0.3 #

  • 修复iOS与其他库共存时,会有重复的错误

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(
        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.9+2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
69
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:sona/sona.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:sona/sona.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:sona/sona.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:sona/sona.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [sona] that is in a package requiring null.

Health suggestions

Fix lib/src/son_data_model.dart. (-0.50 points)

Analysis of lib/src/son_data_model.dart reported 1 hint:

line 24 col 7: The declaration '_RegisterGetuiPushModel' isn't referenced.

Format lib/sona.dart.

Run flutter format to format lib/sona.dart.

Format lib/src/sona_iml.dart.

Run flutter format to format lib/src/sona_iml.dart.

Maintenance suggestions

Package is getting outdated. (-21.10 points)

The package was last published 63 weeks ago.

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

While nothing is inherently wrong with versions of 0.0.*, it might mean 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.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8