|
@@ -15,7 +15,7 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const startFast = (start_time: number, duration: number) => {
|
|
export const startFast = (start_time: number, duration: number) => {
|
|
|
- return new Promise((resolve,reject) => {
|
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
// duration = duration < 3600 * 1000 ? 3600 * 1000 : duration;
|
|
// duration = duration < 3600 * 1000 ? 3600 * 1000 : duration;
|
|
|
const extra = {
|
|
const extra = {
|
|
|
set_time: global.set_time,
|
|
set_time: global.set_time,
|
|
@@ -30,7 +30,7 @@ export const startFast = (start_time: number, duration: number) => {
|
|
|
resolve(res)
|
|
resolve(res)
|
|
|
trackTimeService.send({ type: 'START_FAST' });
|
|
trackTimeService.send({ type: 'START_FAST' });
|
|
|
// getLocalPush()
|
|
// getLocalPush()
|
|
|
- }).catch(e=>{
|
|
|
|
|
|
|
+ }).catch(e => {
|
|
|
reject(e)
|
|
reject(e)
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
@@ -98,7 +98,7 @@ export const endSleep = (start_time: number) => {
|
|
|
reject(e)
|
|
reject(e)
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
-}
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
export const uploadLocalPushInfo = (params) => {
|
|
export const uploadLocalPushInfo = (params) => {
|
|
|
request({
|
|
request({
|
|
@@ -111,12 +111,14 @@ export const uploadLocalPushInfo = (params) => {
|
|
|
|
|
|
|
|
export const getLocalPush = () => {
|
|
export const getLocalPush = () => {
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
- PushNotification.checkPermissions((res)=>{
|
|
|
|
|
|
|
+ console.log('leon aaaaa')
|
|
|
|
|
+ PushNotification.checkPermissions((res) => {
|
|
|
//允许授权
|
|
//允许授权
|
|
|
- if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)){
|
|
|
|
|
|
|
+ if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)) {
|
|
|
request({
|
|
request({
|
|
|
url: API_LOCAL_PUSHES, method: 'GET', data: {}
|
|
url: API_LOCAL_PUSHES, method: 'GET', data: {}
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
|
|
+ console.log('leon aaaaavvv', res)
|
|
|
const { messages } = res as any;
|
|
const { messages } = res as any;
|
|
|
if (messages.length == 0) {
|
|
if (messages.length == 0) {
|
|
|
return;
|
|
return;
|
|
@@ -125,30 +127,35 @@ export const getLocalPush = () => {
|
|
|
onRegister: function (token) {
|
|
onRegister: function (token) {
|
|
|
console.log('TOKEN:', token);
|
|
console.log('TOKEN:', token);
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
onNotification: function (notification) {
|
|
onNotification: function (notification) {
|
|
|
console.log('NOTIFICATION:', notification);
|
|
console.log('NOTIFICATION:', notification);
|
|
|
// notification.finish(PushNotificationIOS.FetchResult.NoData);
|
|
// notification.finish(PushNotificationIOS.FetchResult.NoData);
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
permissions: {
|
|
permissions: {
|
|
|
alert: true,
|
|
alert: true,
|
|
|
badge: true,
|
|
badge: true,
|
|
|
sound: true,
|
|
sound: true,
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
popInitialNotification: true,
|
|
popInitialNotification: true,
|
|
|
requestPermissions: true,
|
|
requestPermissions: true,
|
|
|
});
|
|
});
|
|
|
PushNotification.cancelAllLocalNotifications()
|
|
PushNotification.cancelAllLocalNotifications()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (kIsIOS) {
|
|
if (kIsIOS) {
|
|
|
var Jto = require('react-native').NativeModules.NativeBridge;
|
|
var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
Jto.addLocalPush(messages)
|
|
Jto.addLocalPush(messages)
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ else {
|
|
|
|
|
+ const { HolaModule } = NativeModules
|
|
|
|
|
+ HolaModule.addLocalPush(JSON.stringify(messages))
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
messages.map((item, index) => {
|
|
messages.map((item, index) => {
|
|
|
if (kIsIOS) {
|
|
if (kIsIOS) {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -167,27 +174,33 @@ export const getLocalPush = () => {
|
|
|
vibrate: true, // (optional) default: true. Creates the default vibration pattern if true.
|
|
vibrate: true, // (optional) default: true. Creates the default vibration pattern if true.
|
|
|
}, (created) => {
|
|
}, (created) => {
|
|
|
if (item.mode == 'ONCE') {
|
|
if (item.mode == 'ONCE') {
|
|
|
- PushNotification.localNotificationSchedule({
|
|
|
|
|
- //... You can use all the options from localNotifications
|
|
|
|
|
- channelId: item.id,
|
|
|
|
|
- title: item.title,
|
|
|
|
|
- message: item.body + '\nPress for actions >>', // (required)
|
|
|
|
|
- // date:new Date(new Date().getTime()+10*1000),
|
|
|
|
|
- date: new Date(item.once), // in 60 secs
|
|
|
|
|
- allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
|
|
|
|
|
- messageId: item.id,
|
|
|
|
|
- // repeatType:'minute',
|
|
|
|
|
- /* Android Only Properties */
|
|
|
|
|
-
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ console.log('leon 9528')
|
|
|
|
|
+ if (new Date().getTime() <= item.once) {
|
|
|
|
|
+ console.log('leon 9529')
|
|
|
|
|
+ PushNotification.localNotificationSchedule({
|
|
|
|
|
+ //... You can use all the options from localNotifications
|
|
|
|
|
+ channelId: item.id,
|
|
|
|
|
+ title: item.title,
|
|
|
|
|
+ message: item.body,// + '\nPress for actions >>', // (required)
|
|
|
|
|
+ date: new Date(new Date().getTime() + 10 * 1000),
|
|
|
|
|
+ // date: new Date(item.once), // in 60 secs
|
|
|
|
|
+ allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
|
|
|
|
|
+ messageId: item.id,
|
|
|
|
|
+ // repeatType:'minute',
|
|
|
|
|
+ /* Android Only Properties */
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
else if (item.mode == 'RECURRING') {
|
|
else if (item.mode == 'RECURRING') {
|
|
|
|
|
+ console.log('leon 9527')
|
|
|
const { time, repeat_type } = item.recurring;
|
|
const { time, repeat_type } = item.recurring;
|
|
|
const date = dayjs().format('YYYY-MM-DD')
|
|
const date = dayjs().format('YYYY-MM-DD')
|
|
|
const { HolaModule } = NativeModules
|
|
const { HolaModule } = NativeModules
|
|
|
- HolaModule.addLocalPush(item.title, item.body+ '\nPress for actions >>', time)
|
|
|
|
|
|
|
+ HolaModule.addLocalPush(item.title, item.body + '\nPress for actions >>', time)
|
|
|
return;
|
|
return;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
PushNotification.localNotificationSchedule({
|
|
PushNotification.localNotificationSchedule({
|
|
|
//... You can use all the options from localNotifications
|
|
//... You can use all the options from localNotifications
|
|
|
channelId: item.id,
|
|
channelId: item.id,
|
|
@@ -199,19 +212,19 @@ export const getLocalPush = () => {
|
|
|
repeatType: repeat_type,
|
|
repeatType: repeat_type,
|
|
|
// repeatType:'minute',
|
|
// repeatType:'minute',
|
|
|
/* Android Only Properties */
|
|
/* Android Only Properties */
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
console.log('notificatin push set', messages)
|
|
console.log('notificatin push set', messages)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|