Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onRegisterDevice = (data) => {
const {dispatch, getState} = this.store;
let unsubscribeFromStore = null;
let prefix;
if (Platform.OS === 'ios') {
prefix = General.PUSH_NOTIFY_APPLE_REACT_NATIVE;
if (DeviceInfo.getBundleId().includes('rnbeta')) {
prefix = `${prefix}beta`;
}
} else {
prefix = General.PUSH_NOTIFY_ANDROID_REACT_NATIVE;
}
EphemeralStore.deviceToken = `${prefix}:${data.token}`;
// TODO: Remove when realm is ready
const waitForHydration = () => {
if (getState().views.root.hydrationComplete && !this.configured) {
this.configured = true;
dispatch(setDeviceToken(EphemeralStore.deviceToken));
unsubscribeFromStore();
}
};
const getDeviceInfo = () => ({
apiLevel: Platform.OS === 'ios' ? '' : DeviceInfo.getAPILevel(),
appName: DeviceInfo.getApplicationName(),
brand: DeviceInfo.getBrand(),
buildNumber: DeviceInfo.getBuildNumber(),
bundleId: DeviceInfo.getBundleId(),
deviceCountry: DeviceInfo.getDeviceCountry(),
deviceId: DeviceInfo.getDeviceId(),
deviceLocale: DeviceInfo.getDeviceLocale(),
deviceName: DeviceInfo.getDeviceName(),
firstInstallTime: Platform.OS === 'ios' ? '' : DeviceInfo.getFirstInstallTime(),
freeDiskStorage: DeviceInfo.getFreeDiskStorage(),
referrer: Platform.OS === 'ios' ? '' : DeviceInfo.getInstallReferrer(),
instanceId: Platform.OS === 'ios' ? '' : DeviceInfo.getInstanceID(),
lastUpdateTime: Platform.OS === 'ios' ? '' : DeviceInfo.getLastUpdateTime(),
manufacturer: DeviceInfo.getManufacturer(),
maxMemory: DeviceInfo.getMaxMemory(),
model: DeviceInfo.getModel(),
phoneNumber: Platform.OS === 'ios' ? '' : DeviceInfo.getPhoneNumber(), // 权限http://t.cn/EP3kKhY
readableVersion: DeviceInfo.getReadableVersion(),
serialNumber: Platform.OS === 'ios' ? '' : DeviceInfo.getSerialNumber(),
systemName: DeviceInfo.getSystemName(),
{title: 'Device Unique ID', info: DeviceInfo.getUniqueID()},
{title: 'Device Locale', info: DeviceInfo.getDeviceLocale()},
{title: 'Device Country', info: DeviceInfo.getDeviceCountry()},
{title: 'User Agent', info: DeviceInfo.getUserAgent()},
{title: 'Screen Width', info: Metrics.screenWidth},
{title: 'Screen Height', info: Metrics.screenHeight}
]
const OS_DATA = [
{title: 'Device System Name', info: DeviceInfo.getSystemName()},
{title: 'Device ID', info: DeviceInfo.getDeviceId()},
{title: 'Device Version', info: DeviceInfo.getSystemVersion()}
]
const APP_DATA = [
{title: 'Bundle Id', info: DeviceInfo.getBundleId()},
{title: 'Build Number', info: DeviceInfo.getBuildNumber()},
{title: 'App Version', info: DeviceInfo.getVersion()},
{title: 'App Version (Readable)', info: DeviceInfo.getReadableVersion()}
]
export default class DeviceInfoScreen extends React.Component {
constructor (props) {
super(props)
this.state = {
isConnected: false,
connectionInfo: null,
connectionInfoHistory: []
}
}
const fetchCASSubscription = async (
subscriberID: string,
password: string,
): Promise> => {
const appId = DeviceInfo.getBundleId()
const deviceId = DeviceInfo.getUniqueId()
const res = await fetch(CAS_ENDPOINT_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
appId,
deviceId,
subscriberId: subscriberID,
password: password,
}),
})
return fromResponse(res, {
function screenUniqueName(name) {
return `${DeviceInfo.getBundleId()}.${name}`;
}
const fetchCasSubscription = async (
subscriberID: string,
password: string,
): Promise => {
const appId = DeviceInfo.getBundleId()
const deviceId = DeviceInfo.getUniqueId()
const res = await fetch(CAS_ENDPOINT_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
appId,
deviceId,
subscriberId: subscriberID,
password: password,
}),
})
const json = await res.json()
componentDidMount() {
this.deviceInfo = {
applicationName: DeviceInfo.getApplicationName(),
buildNumber: DeviceInfo.getBuildNumber(),
bundleId: DeviceInfo.getBundleId(),
deviceId: DeviceInfo.getDeviceId(),
readableVersion: DeviceInfo.getReadableVersion(),
version: DeviceInfo.getVersion()
};
}
export const getInstalledVersion = async context => {
const bundleId = RNDeviceInfo.getBundleId()
if (!updateApiSources.hasOwnProperty(bundleId)) {
return null
}
const { channel } = updateApiSources[bundleId]
const deviceData = await DeviceInfos(context).fetch()
const [rawVersionInfo] = deviceData.infos
.filter(d => d.key === 'versions')
.map(d => d.value)
const {
Core: { GitSha: hash, GitBranch: branch, CommitDate: rawCommitDate },
} = JSON.parse(rawVersionInfo)
return {
export const getInstalledVersion = async context => {
const bundleId = RNDeviceInfo.getBundleId()
if (!updateApiSources.hasOwnProperty(bundleId)) {
return null
}
const channel = updateApiSources[bundleId].channel
const deviceData = await context.node.service.deviceInfos({})
const [rawVersionInfo] = deviceData.infos
.filter(d => d.key === 'versions')
.map(d => d.value)
const {
Core: { GitSha: hash, GitBranch: branch, CommitDate: rawCommitDate },
} = JSON.parse(rawVersionInfo)
return {