|
|
@@ -70,6 +70,7 @@ let Linking;
|
|
|
let JPush;
|
|
|
let checkNotification, uploadPermissions, NativeAppEventEmitter;
|
|
|
let messaging;
|
|
|
+let PushNotification;
|
|
|
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
messaging = require('@react-native-firebase/messaging').default
|
|
|
@@ -81,6 +82,7 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
checkNotification = require('@/utils/native_permission_check').checkNotification;
|
|
|
uploadPermissions = require('@/utils/native_permission_check').uploadPermissions;
|
|
|
+ PushNotification = require('react-native-push-notification')
|
|
|
}
|
|
|
|
|
|
const defaultValue = `[{"scenario":{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}},"current_record":{"scenario":"FAST_SLEEP","status":"WAIT_FOR_START","fast":{"status":"WAIT_FOR_START","target_start_time":1710514800000,"target_end_time":1710576000000},"sleep":{"status":"WAIT_FOR_START","target_start_time":1710540000000,"target_end_time":1710572400000}},"wx_pub_followed":false,"time_input_schema":{"min":60,"max":1380,"step":5},"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}},{"scenarios":[{"name":"FAST","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"}}},{"name":"SLEEP","count":0,"schedule":{"sleep":{"start_time":"22:00","end_time":"07:00"}}},{"name":"FAST_SLEEP","count":0,"schedule":{"fast":{"start_time":"15:00","end_time":"08:00"},"sleep":{"start_time":"22:00","end_time":"07:00"}}}],"select_count":0,"theme_color":{"fast":"#00FFFF","sleep":"#8183FF"}}]`
|
|
|
@@ -171,6 +173,57 @@ export default function Page() {
|
|
|
else {
|
|
|
loadRNCache()
|
|
|
|
|
|
+ PushNotification.configure({
|
|
|
+ onRegister: function (token) {
|
|
|
+ console.log('TOKEN:', token);
|
|
|
+ PushNotification.localNotification({
|
|
|
+ channelId: "channel-id-1",
|
|
|
+ title: '推送通知',
|
|
|
+ message: '这是一条本地推送通知',
|
|
|
+ playSound: true,
|
|
|
+ soundName: 'system',
|
|
|
+ });
|
|
|
+
|
|
|
+ PushNotification.localNotification({
|
|
|
+ title: '通知栏推送',
|
|
|
+ message: '这是一条通知栏推送通知',
|
|
|
+ playSound: true,
|
|
|
+ soundName: 'system',
|
|
|
+ android: {
|
|
|
+ priority: 'high',
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ onNotification: function (notification) {
|
|
|
+ console.log('NOTIFICATION:', notification);
|
|
|
+ // notification.finish(PushNotificationIOS.FetchResult.NoData);
|
|
|
+ },
|
|
|
+
|
|
|
+ permissions: {
|
|
|
+ alert: true,
|
|
|
+ badge: true,
|
|
|
+ sound: true,
|
|
|
+ },
|
|
|
+
|
|
|
+ popInitialNotification: true,
|
|
|
+ requestPermissions: true,
|
|
|
+ });
|
|
|
+
|
|
|
+ PushNotification.localNotificationSchedule({
|
|
|
+ //... You can use all the options from localNotifications
|
|
|
+ message: "My Notification Message444", // (required)
|
|
|
+ date: new Date(Date.now() + 10 * 1000), // in 60 secs
|
|
|
+ allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
|
|
|
+
|
|
|
+ /* Android Only Properties */
|
|
|
+ repeatTime: 1, // (optional) Increment of configured repeatType. Check 'Repeating Notifications' section for more info.
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
@@ -220,7 +273,7 @@ export default function Page() {
|
|
|
checkAuthorized();
|
|
|
//检查用户是否添加过小程序
|
|
|
checkAddToMini();
|
|
|
- wxPubFollow({force_refresh:true});
|
|
|
+ wxPubFollow({ force_refresh: true });
|
|
|
|
|
|
|
|
|
|
|
|
@@ -527,7 +580,7 @@ export default function Page() {
|
|
|
|
|
|
|
|
|
function getCheckData() {
|
|
|
-
|
|
|
+
|
|
|
Promise.all([getClocks(), getPlans()]).then((list) => {
|
|
|
setErrorPage(false)
|
|
|
setCheckData(list)
|