AirLink Provisioning
AirLink broadcasts credentials and cannot target a single device. productKeys specifies products for cloud confirmation; timeout is in seconds. This API is exported by the native module only. Supply a result callback; do not directly await the native method’s return value.
import { NativeEventEmitter, NativeModules } from 'react-native';
import type { Types } from 'react-native-gizwits-sdk-v5';
const nativeDeviceManager = NativeModules.RNGizDeviceManagerModule;
const emitter = new NativeEventEmitter(nativeDeviceManager);
const subscription = emitter.addListener('GizProvideWiFiCredentialsEvent', event => {
if (event.data === 'WIFI_CONFIG_SUCCESS' || event.data === 1013) {
console.log('Provisioning succeeded');
}
});
try {
const result = await new Promise<Types.GizResult<unknown, unknown>>(resolve => {
nativeDeviceManager.provideWiFiCredentialsWithAirLink(
{ ssid, password, timeout: 60, productKeys: ['PK1'] },
(error: Types.GizResult<unknown, unknown> | null, data: Types.GizResult<unknown, unknown>) => {
resolve(error ?? data);
},
);
});
if (!result.success) console.log(result.error, result.message);
} finally {
subscription.remove();
}Stop AirLink provisioning (this method takes only a callback, without options):
import type { Types } from 'react-native-gizwits-sdk-v5';
nativeDeviceManager.stopProvideWiFiCredentialsWithAirLink((
error: Types.GizResult<unknown, unknown> | null,
data: Types.GizResult<unknown, unknown>,
) => {
console.log(error ?? data);
});