mobpush_plugin 1.0.5

MobpushPlugin_example #

Demonstrates how to use the MobpushPlugin plugin.

Getting Started #

接口方法说明

(1)设置远程推送环境,向用户授权(仅 iOS):

setCustomNotification

if (Platform.isIOS) {
      MobpushPlugin.setCustomNotification();
}

(2)设置远程推送环境 (仅 iOS):

setAPNsForProduction

if (Platform.isIOS) {
     // 开发环境 false, 线上环境 true
      MobpushPlugin.setAPNsForProduction(false)
}

(3)添加推送回调监听(接收自定义透传消息回调、接收通知消息回调、接收点击通知消息回调、接收别名或标签操作回调)

addPushReceiver

MobpushPlugin.addPushReceiver(_onEvent, _onError);

void _onEvent(Object event) {

}

void _onError(Object event) {
    
}

(4)停止推送

stopPush

MobpushPlugin.stopPush();

(5)重新打开推送服务

restartPush

MobpushPlugin.restartPush();

(6)是否已停止接收推送

isPushStopped

MobpushPlugin.isPushStopped();

(7)设置别名

setAlias

MobpushPlugin.setAlias("别名");

(8)获取别名

getAlias

MobpushPlugin.getAlias();

(9)删除别名

deleteAlias

MobpushPlugin.deleteAlias("别名");

(10)添加标签

addTags

List tags = new List();
tags.add("tag1");
tags.add("tag2");
MobpushPlugin.addTags(tags);

(11)获取标签

getTags

MobpushPlugin.getTags();

(12)删除标签

deleteTags

List tags = new List();
tags.add("tag1");
tags.add("tag2");
MobpushPlugin.deleteTags(tags);

(13)清空标签

cleanTags

MobpushPlugin.cleanTags();

(14)发送本地通知

addLocalNotification

MobpushPlugin.addLocalNotification();

(15)绑定手机号

bindPhoneNum

MobpushPlugin.bindPhoneNum("110");

(16)测试模拟推送,用于测试

send

/**
    * 测试模拟推送,用于测试
    * type:模拟消息类型,1、通知测试;2、内推测试;3、定时
    * content:模拟发送内容,500字节以内,UTF-8
    * space:仅对定时消息有效,单位分钟,默认1分钟
    * extras: 附加数据,json字符串
    */
MobpushPlugin.send(int type, String content, int space, String extras);

(17)设置点击通知是否跳转默认页 (仅andorid)

setClickNotificationToLaunchMainActivity

MobpushPlugin.setClickNotificationToLaunchMainActivity (bool enable);

(18)移除本地通知(仅andorid)

removeLocalNotification

MobpushPlugin.removeLocalNotification(int notificationId);

(19)清空本地通知(仅andorid)

clearLocalNotifications

MobpushPlugin.clearLocalNotifications();

(20)设置通知栏icon,不设置默认取应用icon(仅andorid)

setNotifyIcon

MobpushPlugin.setNotifyIcon(String resId);

(21)设置应用在前台时是否隐藏通知不进行显示,不设置默认不隐藏通知(仅andorid)

setAppForegroundHiddenNotification

MobpushPlugin.setAppForegroundHiddenNotification(bool hidden);

(22)设置通知静音时段(推送选项)(仅andorid)

setSilenceTime

/**
   * 设置通知静音时段(推送选项)(仅andorid)
   * @param startHour   开始时间[0~23] (小时)
   * @param startMinute 开始时间[0~59](分钟)
   * @param endHour     结束时间[0~23](小时)
   * @param endMinute   结束时间[0~59](分钟)
   */
MobpushPlugin.setSilenceTime(int startHour, int startMinute, int endHour, int endMinute)

(23)设置角标 (仅 iOS)

setBadge

MobpushPlugin.setBadge(int badge);

(24)清空角标,不清除通知栏消息记录 (仅 iOS)

clearBadge

MobpushPlugin.clearBadge();

(25)设置应用在前台展示有 Badge、Sound、Alert 三种类型,默认3个选项都有,iOS 10以上设置生效. (仅 iOS)

type: 0->None , 1->仅Badge, 2->仅Sound, 4->仅Alert, 5->Badge+Alert, 6->Sound+Alert, 7->Badge+Sound+Alert

setAPNsShowForegroundType

MobpushPlugin.setAPNsShowForegroundType(int type);

0.0.1 #

  • TODO: Describe initial release.

1.0.1 #

  • Support for mobpush.

1.0.2 #

  • Support all API for MobPush.

1.0.3 #

  • Add How to Use Demo for MobPush.

1.0.4 #

  • 1、完善所有iOS API;
  • 2、提供完整Demo示例;

1.0.5 #

  • 1、iOS 新增设置前台通知展示类型(Badge、Sound、Alert);
  • 2、更新Demo其他API界面为列表展示;

example/README.md

mobpush_plugin_example #

Demonstrates how to use the mobpush_plugin plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  mobpush_plugin: ^1.0.5

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:mobpush_plugin/mobpush_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
12
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
75
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

86 out of 86 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/mobpush_custom_message.dart.

Run flutter format to format lib/mobpush_custom_message.dart.

Format lib/mobpush_local_notification.dart.

Run flutter format to format lib/mobpush_local_notification.dart.

Format lib/mobpush_notify_message.dart.

Run flutter format to format lib/mobpush_notify_message.dart.

Format lib/mobpush_plugin.dart.

Run flutter format to format lib/mobpush_plugin.dart.

Maintenance suggestions

The package description is too short. (-20 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.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test