flutter_jpush 0.0.1

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

flutter_jpush #

Flutter 版本 jpush(极光推送),目前正在开发,预计本周开发完毕,有需求请提issues

ROADMAP #

  • [x] ios
  • [x] android
  • [x] 集成notification
  • [x] 集成message
  • [x] 集成alias
  • [x] 集成tags
  • [ ] 后台接口放出服务
  • [x] 可以运行的例子
  • [x] 用户可相互自行推送

Getting Started #

准备工作 #

申请key #

申请key #

进入这里申请key

ios 证书申请 #

不熟悉怎么申请戳这里

ios 集成 #

android 集成 #

0.0.1 #

  • IOS support

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_jpush/flutter_jpush.dart';
import 'package:flutter_jpush_example/alias_test.dart';
import 'package:flutter_jpush_example/info_test.dart';
import 'package:flutter_jpush_example/push_test.dart';
import 'package:flutter_jpush_example/tag_test.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool isConnected = false;
  String registrationId;
  List notificationList = [];

  int _index = 0;

  @override
  void initState() {
    super.initState();
    _startupJpush();

    FlutterJPush.addConnectionChangeListener((bool connected) {
      setState(() {
        /// 是否连接,连接了才可以推送
        print("连接状态改变:$connected");
        this.isConnected = connected;
        if (connected) {
          FlutterJPush.getRegistrationID().then((String regId) {
            print("主动获取设备号:$regId");
            setState(() {
              this.registrationId = regId;
            });
          });
        }
      });
    });

    FlutterJPush.addnetworkDidLoginListener((String registrationId) {
      setState(() {
        /// 用于推送
        print("收到设备号:$registrationId");
        this.registrationId = registrationId;
      });
    });

    FlutterJPush
        .addReceiveNotificationListener((JPushNotification notification) {
      setState(() {
        /// 收到推送
        print("收到推送提醒: $notification");
        notificationList.add(notification);
      });
    });

    FlutterJPush
        .addReceiveOpenNotificationListener((JPushNotification notification) {
      setState(() {
        print("打开了推送提醒: $notification");

        /// 打开了推送提醒
        notificationList.add(notification);
      });
    });

    FlutterJPush.addReceiveCustomMsgListener((JPushMessage msg) {
      setState(() {
        print("收到推送消息提醒: $msg");

        /// 打开了推送提醒
        notificationList.add(msg);
      });
    });
  }

  void _startupJpush() async {
    print("初始化jpush");
    await FlutterJPush.startup();
    print("初始化jpush成功");
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('JPush Example'),
        ),
        body: new IndexedStack(
          children: <Widget>[
            new Info(
              notificationList: notificationList,
              registrationId: registrationId,
              isConnected: isConnected,
            ),
            new TagSet(),
            new AliasSet(),
            new PushTest()
          ],
          index: _index,
        ),
        bottomNavigationBar: new BottomNavigationBar(
          items: <BottomNavigationBarItem>[
            new BottomNavigationBarItem(
                title: new Text("Info"), icon: new Icon(Icons.info)),
            new BottomNavigationBarItem(
                title: new Text("Tag"), icon: new Icon(Icons.tag_faces)),
            new BottomNavigationBarItem(
                title: new Text("Alias"), icon: new Icon(Icons.nature)),
          ],
          onTap: (int index) {
            setState(() {
              _index = index;
            });
          },
          currentIndex: _index,
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_jpush: ^0.0.1

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:flutter_jpush/flutter_jpush.dart';
  
Version Uploaded Documentation Archive
0.0.4 Sep 12, 2018 Go to the documentation of flutter_jpush 0.0.4 Download flutter_jpush 0.0.4 archive
0.0.3 Sep 11, 2018 Go to the documentation of flutter_jpush 0.0.3 Download flutter_jpush 0.0.3 archive
0.0.2 Sep 6, 2018 Go to the documentation of flutter_jpush 0.0.2 Download flutter_jpush 0.0.2 archive
0.0.1 Sep 6, 2018 Go to the documentation of flutter_jpush 0.0.1 Download flutter_jpush 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
79
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
55
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15
  • Flutter: 1.5.8

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/flutter_jpush.dart. (-21.38 points)

Analysis of lib/flutter_jpush.dart reported 48 hints, including:

line 152 col 16: Don't explicitly initialize variables to null.

line 220 col 3: Prefer using /// for doc comments.

line 231 col 3: Prefer using /// for doc comments.

line 240 col 3: Prefer using /// for doc comments.

line 247 col 3: Prefer using /// for doc comments.

Maintenance issues and suggestions

The description contains too many non-ASCII characters. (-20 points)

The site uses English as its primary language. The value of the description field in your package's pubspec.yaml field should primarily contain characters used in English.

The package description is too short. (-15 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

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.48.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8