Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(navContext) {
super();
this._bluetooth.debug = false;
this.peripheral = navContext.peripheral;
this.advertismentData = navContext.peripheral.advertismentData as AdvertismentData;
console.log('peripheral', JSON.stringify(this.peripheral));
console.log('advertismentData', JSON.stringify(this.advertismentData));
console.log('serviceData', JSON.stringify(this.advertismentData.serviceData));
console.log('uuids', this.advertismentData.serviceUUIDs);
console.log('txPowerLevel', this.advertismentData.txPowerLevel);
applicationOn(suspendEvent, this.onAppPause, this);
applicationOn(resumeEvent, this.onAppResume, this);
// console.log('localName', this.advertismentData.localName);
// console.log('serviceUUIDs', this.advertismentData.serviceUUIDs);
// console.log('txPowerLevel', this.advertismentData.txPowerLevel);
// console.log('flags', this.advertismentData.flags);
// console.log('manufacturerId', this.advertismentData.manufacturerId);
// console.log('manufacturerData', this.advertismentData.manufacturerData);
// console.log('serviceData', this.advertismentData.serviceData);
}
onAppResume(args: ApplicationEventData) {
function setupConfigListener() {
nsApp.off(nsApp.launchEvent, setupConfigListener);
const context = nsApp.android && (nsApp.android.context as android.content.Context);
if (!context) {
nsApp.on(nsApp.launchEvent, setupConfigListener);
return;
}
useAndroidFontScale();
let configChangedCallback = new android.content.ComponentCallbacks2({
onLowMemory() {
// Dummy
},
onTrimMemory() {
// Dummy
},
onConfigurationChanged(newConfig: android.content.res.Configuration) {
fontScaleChanged(Number(newConfig.fontScale));
},
useAndroidFontScale();
let configChangedCallback = new android.content.ComponentCallbacks2({
onLowMemory() {
// Dummy
},
onTrimMemory() {
// Dummy
},
onConfigurationChanged(newConfig: android.content.res.Configuration) {
fontScaleChanged(Number(newConfig.fontScale));
},
});
context.registerComponentCallbacks(configChangedCallback);
nsApp.on(nsApp.resumeEvent, useAndroidFontScale);
}
}
function useIOSFontScale() {
if (nsApp.ios.nativeApp) {
contentSizeUpdated(nsApp.ios.nativeApp.preferredContentSizeCategory);
} else {
fontScaleChanged(1);
}
}
const fontSizeObserver = nsApp.ios.addNotificationObserver(UIContentSizeCategoryDidChangeNotification, (args) => {
const fontSize = args.userInfo.valueForKey(UIContentSizeCategoryNewValueKey);
contentSizeUpdated(fontSize);
});
nsApp.on(nsApp.exitEvent, () => {
nsApp.ios.removeNotificationObserver(fontSizeObserver, UIContentSizeCategoryDidChangeNotification);
internalObservable = null;
nsApp.off(nsApp.resumeEvent, useIOSFontScale);
});
nsApp.on(nsApp.resumeEvent, useIOSFontScale);
useIOSFontScale();
}
}
}
const fontSizeObserver = nsApp.ios.addNotificationObserver(UIContentSizeCategoryDidChangeNotification, (args) => {
const fontSize = args.userInfo.valueForKey(UIContentSizeCategoryNewValueKey);
contentSizeUpdated(fontSize);
});
nsApp.on(nsApp.exitEvent, () => {
nsApp.ios.removeNotificationObserver(fontSizeObserver, UIContentSizeCategoryDidChangeNotification);
internalObservable = null;
nsApp.off(nsApp.resumeEvent, useIOSFontScale);
});
nsApp.on(nsApp.resumeEvent, useIOSFontScale);
useIOSFontScale();
}
);
nsApp.on(nsApp.exitEvent, () => {
if (nativeObserver) {
nsApp.ios.removeNotificationObserver(nativeObserver, UIAccessibilityVoiceOverStatusChanged);
}
nativeObserver = null;
if (sharedA11YObservable) {
sharedA11YObservable.removeEventListener(Observable.propertyChangeEvent);
sharedA11YObservable = null;
}
});
}
nsApp.on(nsApp.resumeEvent, () => sharedA11YObservable.set('isAccessibilityServiceEnabled', isAccessibilityServiceEnabled()));
return sharedA11YObservable;
}
constructor() {
super(isAccessibilityServiceEnabled());
nsApp.on(nsApp.resumeEvent, this.resumeEvent, this);
this.tnsObs.on(AccessibilityServiceEnabledObservable.propertyChangeEvent, this.tnsPropertyValueChanged, this);
}
function ensureStateListener() {
if (sharedA11YObservable) {
return sharedA11YObservable;
}
sharedA11YObservable = new Observable() as SharedA11YObservable;
sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isAccessibilityServiceEnabled());
if (typeof UIAccessibilityVoiceOverStatusDidChangeNotification !== 'undefined') {
nativeObserver = nsApp.ios.addNotificationObserver(UIAccessibilityVoiceOverStatusDidChangeNotification, () =>
sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isAccessibilityServiceEnabled()),
);
nsApp.on(nsApp.exitEvent, () => {
if (nativeObserver) {
nsApp.ios.removeNotificationObserver(nativeObserver, UIAccessibilityVoiceOverStatusDidChangeNotification);
}
nativeObserver = null;
sharedA11YObservable = null;
});
} else if (typeof UIAccessibilityVoiceOverStatusChanged !== 'undefined') {
nativeObserver = nsApp.ios.addNotificationObserver(UIAccessibilityVoiceOverStatusChanged, () =>
sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isAccessibilityServiceEnabled()),
);
nsApp.on(nsApp.exitEvent, () => {
if (nativeObserver) {
nsApp.ios.removeNotificationObserver(nativeObserver, UIAccessibilityVoiceOverStatusChanged);
}