Added Frontend
This commit is contained in:
32
frontend/composables/useCapacitor.js
Normal file
32
frontend/composables/useCapacitor.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import {Capacitor} from "@capacitor/core";
|
||||
import {Device} from "@capacitor/device";
|
||||
import {Network} from "@capacitor/network";
|
||||
|
||||
const override = false
|
||||
|
||||
export const useCapacitor = () => {
|
||||
const getPlatform = () => {
|
||||
return Capacitor.getPlatform()
|
||||
}
|
||||
|
||||
const getDeviceInfo = async () => {
|
||||
return await Device.getInfo()
|
||||
}
|
||||
|
||||
const getIsPhone = async () => {
|
||||
let deviceInfo = await useCapacitor().getDeviceInfo()
|
||||
|
||||
return override || deviceInfo.model.toLowerCase().includes('iphone')
|
||||
}
|
||||
|
||||
const getIsNative = () => {
|
||||
return override || Capacitor.isNativePlatform()
|
||||
}
|
||||
|
||||
const getNetworkStatus = async () => {
|
||||
return await Network.getStatus()
|
||||
}
|
||||
|
||||
|
||||
return {getPlatform, getDeviceInfo, getNetworkStatus, getIsPhone, getIsNative}
|
||||
}
|
||||
Reference in New Issue
Block a user