| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import { getLocalPush } from '@/features/trackTimeDuration/actions/TrackTimeActions';
- import { clientInfo } from '@/services/common';
- import Taro from '@tarojs/taro';
- import { Alert, Linking } from 'react-native';
- import { check, PERMISSIONS, RESULTS, checkMultiple } from 'react-native-permissions';
- import { kIsIOS } from './tools';
- // import {OneSignal} from 'react-native-onesignal';
- export const uploadPermissions = () => {
- if (Taro.getSystemInfoSync().platform == 'android') {
- checkMultiple([PERMISSIONS.ANDROID.CAMERA,
- PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION,
- PERMISSIONS.ANDROID.POST_NOTIFICATIONS]).then(statuses => {
- // const OneSignal = require('react-native-onesignal').OneSignal
- // OneSignal.initialize("2bbf5339-7ab8-4c5c-9a66-c3a8eaea188e");
- // OneSignal.Notifications.getPermissionAsync().then((res) => {
- // if (res) {
- // global.notification = 'authorized'
- // }
- // else {
- // global.notification = 'denied'
- // }
- // var Jto = require('react-native').NativeModules.NativeBridge;
- // Jto.checkSystemLocationService().then(enableLocation => {
- // clientInfo({
- // perm: {
- // android: {
- // camera: statuses[PERMISSIONS.ANDROID.CAMERA],
- // location: {
- // location_services_enabled: enableLocation,
- // authorization_status: statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION]
- // },
- // notification: {
- // authorization_status: global.notification
- // }
- // }
- // }
- // })
- // })
- // })
- });
- return
- }
- checkMultiple([PERMISSIONS.IOS.CAMERA,
- PERMISSIONS.IOS.PHOTO_LIBRARY,
- PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
- PERMISSIONS.IOS.LOCATION_ALWAYS]).then(statuses => {
- // getLocalPush()
- var Jto = require('react-native').NativeModules.NativeBridge;
- Jto.getLocationAuthStatus((res) => {
- clientInfo({
- perm: {
- ios: {
- album: statuses[PERMISSIONS.IOS.PHOTO_LIBRARY],
- camera: statuses[PERMISSIONS.IOS.CAMERA],
- location: res,
- notification: {
- authorization_status: global.notification
- }
- }
- }
- })
- })
- })
- }
- export const checkNotification = () => {
- if (Taro.getSystemInfoSync().platform == 'android') {
- // const OneSignal = require('react-native-onesignal').OneSignal
- // OneSignal.Notifications.canRequestPermission().then((res) => {
- // if (res) {
- // OneSignal.Notifications.requestPermission(true);
- // }
- // else {
- // Linking.openSettings()
- // }
- // })
- return;
- }
- if (global.notification == 'not_determined') {
- if (kIsIOS) {
- var Jto = require('react-native').NativeModules.NativeBridge;
- Jto.authNotification()
- }
- else {
- // Linking.openSettings()
- // const OneSignal = require('react-native-onesignal').OneSignal
- // OneSignal.Notifications.requestPermission(true).then((response) => {
- // if (response) {
- // global.notification = 'authorized'
- // uploadPermissions()
- // } else {
- // global.notification = 'denied'
- // uploadPermissions()
- // }
- // });
- }
- // const test = require('@/utils/push').default
- // test()
- }
- else {
- if (kIsIOS) {
- Linking.openURL('app-settings:notifications')
- }
- else {
- Linking.openSettings()
- }
- }
- }
|