当前位置:网站首页>Flutter integrated Aurora push
Flutter integrated Aurora push
2022-07-26 12:55:00 【Flutter Mengxin College】
pubspec.yaml Import plug-ins
# Aurora push
jpush_flutter: 0.6.3
Flutter newly build Push Management category
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:lcpay_app/common/config/appConfig.dart';
import 'package:lcpay_app/router/router_manger.dart';
import 'package:lcpay_app/utils/logUtils.dart';
import 'package:localstorage/localstorage.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sp_util/sp_util.dart';
import '../../main.dart';
final JPushManager jPushManager = JPushManager();
class JPushManager {
factory JPushManager() => _sharedInstance();
static JPushManager _instance;
static JPushManager _sharedInstance() {
if (_instance == null) {
_instance = JPushManager._();
}
return _instance;
}
JPushManager._() {
_jpush = JPush();
_jpush.addEventHandler(
// Receive notification callback method .
onReceiveNotification: _onReceiveNotification,
// Click the notification callback method .
onOpenNotification: _onOpenNotification,
// Receive custom message callback method .
onReceiveMessage: _onReceiveMessage,
onReceiveNotificationAuthorization: _onReceiveNotificationAuthorization,
);
}
JPush _jpush;
Future setup() async {
_jpush.setup(
appKey: “XXXXXXX”, // You use it yourself AppKey
channel: "developer-default",
production: true, // Whether the production environment
debug: true, //debug be Print log
);
_jpush.applyPushAuthority(
NotificationSettingsIOS(sound: true, alert: true, badge: true));
// _jpush.clearAllNotifications();
// _jpush.setBadge(0);
}
// Set alias
void setAlias(String alias) {
_jpush.setAlias(alias);
}
// Set up tags
void setTags(List<String> tags) {
_jpush.setTags(tags);
}
// obtain RegistrationID
Future<String> getRegistrationID() async {
try {
return await _jpush.getRegistrationID();
} catch (e, s) {
LogUtils.d(s);
return "";
}
}
Future<dynamic> _onReceiveNotification(Map<String, dynamic> message) async {
LogUtils.d("flutter onReceiveNotification: $message");
}
Future<dynamic> _onOpenNotification(Map<String, dynamic> message) async {
//TODO Click notice here analysis data Jump to the corresponding route respectively
LogUtils.d("flutter onOpenNotification: $message");
}
Future<dynamic> _onReceiveMessage(Map<String, dynamic> message) async {
LogUtils.d("flutter onReceiveMessage: $message");
}
Future<dynamic> _onReceiveNotificationAuthorization(
Map<String, dynamic> message) async {
LogUtils.d("flutter onReceiveNotificationAuthorization: $message");
}
}
//JPushManager stay main In the initialization
void main() {
runApp(MyApp());
jPushManager.setup();// JPush initialization
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
.....}
// Add globally on other pages tags If added after login tags,
List<String> tagList = [userInfo.id]; // Such as I put usrId As tag
jPushManager.setTags(tagList); // Global add
android iOS You also need to configure Reference resources Official plug-in example
边栏推荐
- 数据查询函数
- Bitwise and how to write SQL
- mqtt send receive
- In the digital era, what "golden treasure" is driving the development of pharmaceutical enterprises for a century?
- New function | intelligent open search online customized word weight model
- Commonly used list Why does isempty() suddenly report null?
- STM32 drives hc05 Bluetooth serial port communication module
- A super easy-to-use artifact apifox, throw swagger a few streets... (glory Collection Edition)
- Data query of MySQL (aggregate function)
- 回溯——46. 全排列
猜你喜欢

C regards type as generic type T and uses it as generic type of method

Vs code set the method of ctrl+s saving and automatic formatting

食品安全 | 无菌蛋真的完全无菌吗?

(int argc, char** argv) command line parameters in visual stdio (VS)

回溯——第51题. N皇后——必须攻克的经典回溯难题

Food safety | these common foods are poisonous! Check your dining table quickly

什么是回调函数,对于“回”字的理解

From January to June, China's ADAS suppliers accounted for 9%, and another parts giant comprehensively laid out the new smart drive track

高通再次「押宝」中科创达,挑战智能驾驶软硬件全栈方案

【5G】5G中的CU和DU是什么?
随机推荐
华为超融合FusionCube解决方案笔记
A super easy-to-use artifact apifox, throw swagger a few streets... (glory Collection Edition)
mqtt send receive
Detailed explanation of redis's single login
SLAM 02.整体框架
.eslintrc.js configuration description
LCD notes (4) analyze the LCD driver of the kernel
Examples of ThreadLocal usage scenarios under multithreading
编程式导航路由跳转到当前路由(参数不变), 多次执行会抛出NavigationDuplicated的警告错误?
If there is a declaration "int x=5, y=1;", Then the expression x < y? The result of x++: y++ is:
New function | intelligent open search online customized word weight model
Food safety | can you eat any fruit?
食品安全 | 微波炉什么食品都能加热?这些安全隐患要知道
jvm:类加载子系统干什么的?由什么组成?需要记住哪些八股文?
Problems and solutions in the learning process of file class
[map] universal map usage & two ways of fuzzy query
PXE principle and configuration
PXE原理与配置
Remote IP debugger (Practical dry goods)
高通再次「押宝」中科创达,挑战智能驾驶软硬件全栈方案