|
|
@@ -22,6 +22,7 @@ import vantEnUS from 'vant/es/locale/lang/en-US'
|
|
|
import { useStorage } from '@vueuse/core'
|
|
|
import { init as initEruda } from '@/utils/console'
|
|
|
import { codePush, InstallMode } from 'capacitor-codepush'
|
|
|
+import { SyncStatus } from 'capacitor-codepush/dist/esm/syncStatus'
|
|
|
import { Network } from '@capacitor/network'
|
|
|
import { Facebook } from 'capacitor-facebook'
|
|
|
|
|
|
@@ -77,9 +78,6 @@ if (navigator.language === 'zh-CN') {
|
|
|
} else {
|
|
|
setDefaultOptions({ locale: enUS })
|
|
|
}
|
|
|
-document.addEventListener('online', () => {
|
|
|
- console.log('online')
|
|
|
-})
|
|
|
document.addEventListener('deviceready', () => {
|
|
|
console.log('deviceready')
|
|
|
if (Capacitor.isNativePlatform()) {
|
|
|
@@ -111,54 +109,20 @@ document.addEventListener('deviceready', () => {
|
|
|
// console.log('install data:', data)
|
|
|
// handleData(data)
|
|
|
// })
|
|
|
- const afConfig = {
|
|
|
- appID: 'id1665426567', // replace with your app ID.
|
|
|
- devKey: Capacitor.getPlatform() === 'android' ? 'xiQnptYGJ44kMBgmR3esZC' : 'QFfmCXsWbhqgRiXsWx7b2o', // replace with your dev key.
|
|
|
- isDebug: true,
|
|
|
- waitForATTUserAuthorization: 10, // for iOS 14 and higher
|
|
|
- minTimeBetweenSessions: 6, // default 5 sec
|
|
|
- registerOnDeepLink: true,
|
|
|
- registerConversionListener: true,
|
|
|
- registerOnAppOpenAttribution: false,
|
|
|
- deepLinkTimeout: 4000, // default 3000 ms
|
|
|
- useReceiptValidationSandbox: true, // iOS only
|
|
|
- useUninstallSandbox: true // iOS only
|
|
|
- }
|
|
|
-
|
|
|
- AppsFlyer.initSDK(afConfig)
|
|
|
- .then(res => {
|
|
|
- console.log('initSDK: ', res)
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
- console.log('initSDK error: ', e)
|
|
|
- })
|
|
|
- AppsFlyer.addListener(AFConstants.CONVERSION_CALLBACK, res => {
|
|
|
- console.log('CONVERSION_CALLBACK:', res)
|
|
|
- })
|
|
|
- AppsFlyer.addListener(AFConstants.OAOA_CALLBACK, res => {
|
|
|
- console.log('OAOA_CALLBACK: ', res)
|
|
|
- })
|
|
|
- AppsFlyer.addListener(AFConstants.UDL_CALLBACK, res => {
|
|
|
- console.log('UDL_CALLBACK: ', res)
|
|
|
- })
|
|
|
- AppsFlyer.setAppInviteOneLink({
|
|
|
- onelinkID: 'cQAJ'
|
|
|
- })
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- SplashScreen.hide()
|
|
|
- }, 1000)
|
|
|
- window.codePush = codePush
|
|
|
- window.InstallMode = InstallMode
|
|
|
- const checkUpdate = () => {
|
|
|
+ const checkUpdate = async () => {
|
|
|
+ if (!location.origin.includes('localhost')) return
|
|
|
codePush
|
|
|
.sync(
|
|
|
{
|
|
|
updateDialog: false,
|
|
|
- installMode: InstallMode.IMMEDIATE,
|
|
|
+ installMode:
|
|
|
+ localStorage.getItem('firstRun') === '1'
|
|
|
+ ? InstallMode.ON_NEXT_RESTART
|
|
|
+ : InstallMode.IMMEDIATE,
|
|
|
ignoreFailedUpdates: false
|
|
|
},
|
|
|
downloadProgress => {
|
|
|
+ console.log(downloadProgress)
|
|
|
if (downloadProgress) {
|
|
|
console.log(
|
|
|
`Downloading ${downloadProgress.receivedBytes} of ${downloadProgress.totalBytes}`
|
|
|
@@ -167,15 +131,18 @@ document.addEventListener('deviceready', () => {
|
|
|
}
|
|
|
)
|
|
|
.then(status => {
|
|
|
- console.log('codePush sync status:', status)
|
|
|
+ console.log('codePush sync status:', SyncStatus[status])
|
|
|
+ if (status === SyncStatus.UP_TO_DATE) {
|
|
|
+ initAF()
|
|
|
+ }
|
|
|
})
|
|
|
+ localStorage.setItem('firstRun', '1')
|
|
|
}
|
|
|
- Network.addListener('networkStatusChange', status => {
|
|
|
- console.log('networkStatusChange:', status)
|
|
|
- if (status.connected) {
|
|
|
- //checkUpdate()
|
|
|
- }
|
|
|
- })
|
|
|
+ // Network.addListener('networkStatusChange', status => {
|
|
|
+ // if (status.connected) {
|
|
|
+ // //checkUpdate()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
Network.getStatus().then(status => {
|
|
|
console.log('networkStatus:', status)
|
|
|
if (status.connected) {
|
|
|
@@ -184,11 +151,49 @@ document.addEventListener('deviceready', () => {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+const initAF = () => {
|
|
|
+ const afConfig = {
|
|
|
+ appID: 'id1665426567', // replace with your app ID.
|
|
|
+ devKey: Capacitor.getPlatform() === 'android' ? 'xiQnptYGJ44kMBgmR3esZC' : 'QFfmCXsWbhqgRiXsWx7b2o', // replace with your dev key.
|
|
|
+ isDebug: false,
|
|
|
+ waitForATTUserAuthorization: 10, // for iOS 14 and higher
|
|
|
+ registerOnDeepLink: true,
|
|
|
+ registerConversionListener: true,
|
|
|
+ registerOnAppOpenAttribution: true,
|
|
|
+ deepLinkTimeout: 4000, // default 3000 ms
|
|
|
+ useReceiptValidationSandbox: true, // iOS only
|
|
|
+ useUninstallSandbox: true // iOS only
|
|
|
+ }
|
|
|
+
|
|
|
+ AppsFlyer.initSDK(afConfig)
|
|
|
+ .then(res => {
|
|
|
+ console.log('AppsFlyer initSDK success')
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log('initSDK error: ', e)
|
|
|
+ })
|
|
|
+ AppsFlyer.addListener(AFConstants.CONVERSION_CALLBACK, res => {
|
|
|
+ console.log('CONVERSION_CALLBACK:', res)
|
|
|
+ })
|
|
|
+ AppsFlyer.addListener(AFConstants.OAOA_CALLBACK, res => {
|
|
|
+ console.log('OAOA_CALLBACK: ', res)
|
|
|
+ })
|
|
|
+ AppsFlyer.addListener(AFConstants.UDL_CALLBACK, event => {
|
|
|
+ if (event.callbackName === AFConstants.onConversionDataSuccess) {
|
|
|
+ console.log('ConversionData: ', event.data)
|
|
|
+ if (event.data.invitor) {
|
|
|
+ localStorage.setItem('invitor', event.data.invitor)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ AppsFlyer.setAppInviteOneLink({
|
|
|
+ onelinkID: 'cQAJ'
|
|
|
+ })
|
|
|
+}
|
|
|
Facebook.init({ appId: '683776590201632', pixelId: '557748303040652' }).then(() => {
|
|
|
console.log('FacebookSDK initialized')
|
|
|
})
|
|
|
|
|
|
-// if (useStorage('showConsole', 0).value > new Date().getTime()) {
|
|
|
-// initEruda()
|
|
|
-// }
|
|
|
-initEruda()
|
|
|
+if (useStorage('showConsole', 0).value > new Date().getTime()) {
|
|
|
+ initEruda()
|
|
|
+}
|