Can't read item in Android, works in IOS
See original GitHub issueI am setting up push notifications with react native firebase and have followed this tutorial:
https://medium.com/@anum.amin/react-native-integrating-push-notifications-using-fcm-349fff071591
Everything works fine on IOS, but for android I can’t get it working and it seems that the issue is due to async storage.
This is my current toggle for turning notifications on:
export const toggleNotifications = (channel) => {
return async (dispatch, state) => {
const currentUserID = firebaseService.auth().currentUser.uid;
const channelNotification = FIREBASE_REF_NOTIFICATIONS.child(channel).child(currentUserID)
let fcmToken = await AsyncStorage.getItem('fcmToken');
// ON IOS THIS COMES BACK AS TOKEN
// ON ANDROID I GET NULL
alert(fcmToken)
channelNotification.set(fcmToken)
dispatch(loadNotificationsSuccess(channel, fcmToken))
}
}
Here are the versions I am using:
"@react-native-community/async-storage": "^1.6.3",
"react-native": "0.60.5",
Why would I be getting back the token for IOS, but not android? If I put an alert in my initial render I get the same response for each so I think fetching the token works-
render() {
alert(JSON.stringify(AsyncStorage.getItem('fcmToken')))
return (
<Provider store={store}>
<ChatApp />
</Provider>)
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Move from Android to iPhone, iPad, or iPod touch
On your Android device, open the Move to iOS app. If you don't have the Move to iOS app, you can tap the...
Read more >Use Select to Speak - Android Accessibility Help
You can select items on your screen and hear them read or described aloud with Select to Speak for Android. Step 1: Turn...
Read more >Troubleshooting | Home Assistant Companion Docs
If you can't see this, force quit on iOS or force stop on Android. Then relaunch the Companion app and finally restart your...
Read more >Troubleshoot OneDrive for Android app problems
Learn how to resolve issues with the OneDrive mobile app.
Read more >Resolving the “Unable to Download Item. Please Try Again ...
A somewhat strange error message can occur at random on iOS, typically for iPhone users, that states “Unable to Download Item.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Krizzu thanks for the help. I can’t reproduce anymore and it’s working now. I rolled back my code to before I tried to implement push notifications due to another bug and didn’t see async anywhere. My guess is you were right and somehow it was using async as a dependency vs the community version. Thanks for the help
@Sbphillips19 you can run
react-native log-android
in your terminal to see logs.Search through
node_modules
forAsyncStorage
key.