Open WooMinGy opened 5 months ago
Hi @WooMinGy, thank you for reporting this bug. We will make the fix to return boolean as expected on iOS.
@nan-li , thank you for checking the reporting quickly. Please let me know after it has been fixed.
I am also falling into this issue, any updates since Feb @nan-li?
The workaround in the meantime is to override the types and unwrap the array:
// FIXME: iOS returns a boolean tuple so unwrap it to provide a boolean as expected
// @see https://github.com/OneSignal/react-native-onesignal/issues/1655
const value = (await OneSignal.Notifications.requestPermission(true)) as boolean | [boolean];
const granted = Array.isArray(value) ? value[0] : value;
// `granted` is now always a boolean as per the types
What happened?
react-native: 0.73.2 device: iphone 12 mini iOS version: 17.3.1 onesignal version: 5.0.5
I implemented actions to change based on whether the return value of requestPermission is true or false. However, the actions did not occur as specified on iOS. Upon checking, I found that the returned value was coming in as an array.
Below is a photo of my code and the result values confirmed via console.log.
Steps to reproduce?
What did you expect to happen?
It should have returned a Promise as the specified type. On Android, it correctly returns a boolean, but on iOS, it is returning a Promise<boolean[]> instead.
React Native OneSignal SDK version
Release 5.0.5
Which platform(s) are affected?
Relevant log output
No response
Code of Conduct