-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform not detected correctly on Android (Platform.OS) #30178
Comments
similar problem, but my Platform.OS resolves to "false". This breaks linkages to native components and crashes the app. e.g.
Any idea how to fix this? |
I have a similar problem, Platform.OS does not work well, sometimes it returns the correct value but other times it always returns false. |
Updating this issue, I recently managed to reproduce it again in a different way. This time, it has nothing to do with saving any file and the metro bundler rebundling the app. It still thinks the value is Alternative reproduction steps:
You will see that it thinks the platform is "clearOneSignalNotifications: this function is not supported on iOS" A message coming from this line in the OneSignal library... static clearOneSignalNotifications() {
if (!checkIfInitialized(RNOneSignal)) return;
if (Platform.OS === 'android') {
RNOneSignal.clearOneSignalNotifications();
} else {
console.log("clearOneSignalNotifications: this function is not supported on iOS");
}
} and to be clear, |
Just an update from my side, this was my user error. I found an instance in my app where I had accidentally tried to assign Platform.OS a value (I.e. Platform.OS = "ios"). This broke the Platform module and it never recovered until a restart. |
An update, I had the exact same issue as @Svarto . |
I had this silly error, I just fixed the error and work for me, thanks! |
Description
The issue is simple,
Platform
is not detecting Android correctly in some instances. I am only ever able to reproduce the issue when I save myApp.js
file and React Native reloads the app. This is causing the OneSignal SDK package that also usesPlatform
to fall into an iOS-only code path (here).React Native version:
Steps To Reproduce
Open the
android
directory with Android Studio and fix any build issues like signing config keystore , gradle, etc...react-native run-android
Send yourself a notification by tapping the button "Post a Notification"
Open App.js, on line 401 try playing with the 3rd argument. Change the line to
OneSignal.postNotification({en:"Testing this post"}, {data:"data"}, state.userId);
(i.e. remove the brackets from the last argument).Somehow I can consistently reproduce the issue by doing that (send notif, remove brackets, save).
Expected Results
I expect the log not to print that the platform is iOS, since I am running this on Android.
Snack, code example, screenshot, or link to a repository:
See line 394 in App.js from the repository.
SCREENSHOTS
The text was updated successfully, but these errors were encountered: