Open ludufre opened 2 years ago
@ludufre Thank you, we will update this. In the meantime, does OneSignal.getDeviceState((state) => { .. })
work for you?
@ludufre Thank you, we will update this. In the meantime, does
OneSignal.getDeviceState((state) => { .. })
work for you?
I can't compile with that. I'm temporary have using:
window['plugins'].OneSignal.getDeviceState((state) => { .. });
+1 we have the same issue. We're using Ionic5, Capacitor3, OneSignal plugin v3.0.0. Can't use promise, have to use window['plugins'] notation.
Would love to see promises implemented. Until now the TypeScript types are just wrong in order to be able to compile I used:
(OneSignal as any).getDeviceState((status) => { ... });
Sad thing is that the purpose of types is gone that way unless I manually import DeviceState
:
import { DeviceState } from 'onesignal-cordova-plugin/types/Subscription';
(OneSignal as any).getDeviceState((status: DeviceState) => { ... });
Alternatively wrap in Promise for async:
const status: DeviceState = await new Promise((resolve) => (OneSignal as any).getDeviceState(resolve));
Description:
The type definition of the method
OneSignal.getDeviceState
isPromise<DeviceState>
but the correct call need a callbackOneSignal.getDeviceState((state) => { .. })
.I'm using Ionic, so I import with
import OneSignal from 'onesignal-cordova-plugin';
. To use the correct call of the getDeviceState I had to use:If I use as Promise I get error:
Environment
Steps to Reproduce Issue:
Add
import OneSignal from 'onesignal-cordova-plugin';
Try to call: