30 lines
739 B
JavaScript
30 lines
739 B
JavaScript
import {Capacitor} from "@capacitor/core";
|
|
import {Device} from "@capacitor/device";
|
|
import {Network} from "@capacitor/network";
|
|
|
|
export const useCapacitor = () => {
|
|
const getPlatform = () => {
|
|
return Capacitor.getPlatform()
|
|
}
|
|
|
|
const getDeviceInfo = async () => {
|
|
return await Device.getInfo()
|
|
}
|
|
|
|
const getIsPhone = async () => {
|
|
let deviceInfo = await useCapacitor().getDeviceInfo()
|
|
|
|
if(deviceInfo.model.toLowerCase().includes('iphone')) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
const getNetworkStatus = async () => {
|
|
return await Network.getStatus()
|
|
}
|
|
|
|
|
|
return {getPlatform, getDeviceInfo, getNetworkStatus, getIsPhone}
|
|
} |