app-starlock/star_lock/lib/tools/xs_jPhush.dart
Daisy 42ec6adda9 1,修复对讲呼叫接听无应答持续性无法自动断开问题
2,根据锁类型显示锁详情相关权限(全自动锁-视频日志)
3,修复全自动锁点击接听需点两次才能接听问题
4,获取相机权限优化逻辑
2024-03-22 13:51:30 +08:00

54 lines
1.8 KiB
Dart

import 'dart:io';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/storage.dart';
class XSJPushProvider {
final JPush jpush = JPush();
Future<void> initJPushService() async {
final data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
jpush.setup(
appKey: "7ff37d174c1a568a89e98dad",
channel: "flutter_channel",
production: false,
debug: true,
);
jpush.addEventHandler(
// 接收通知回调方法。
onReceiveNotification: (Map<String, dynamic> message) async {
print("flutter onReceiveNotification: $message");
},
// 点击通知回调方法。
onOpenNotification: (Map<String, dynamic> message) async {
print("flutter onOpenNotification: $message");
},
// 接收自定义消息回调方法。
onReceiveMessage: (Map<String, dynamic> message) async {
print("flutter onReceiveMessage: $message");
},
);
jpush.applyPushAuthority(
const NotificationSettingsIOS(sound: true, alert: true, badge: true));
// jpush.setChannelAndSound(
// channel: "flutter_channel", channelID: "115700", sound: "default");
// Platform messages may fail, so we use a try/catch PlatformException.
jpush.getRegistrationID().then((rid) {
print("flutter get registration id : $rid");
pushBindDeviceID(rid, Platform.isAndroid ? 10 : 20);
});
}
}
void pushBindDeviceID(String deviceID, int deviceType) async {
var entity = await ApiRepository.to.pushBindAppId(deviceID, deviceType);
if (entity.errorCode!.codeIsSuccessful) {}
}
}