question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't read item in Android, works in IOS

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Sbphillips19commented, Nov 27, 2019

@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

0reactions
krizzucommented, Nov 25, 2019

@Sbphillips19 you can run react-native log-android in your terminal to see logs.

how would I completely remove the old async storage? I thought by importing the community version it would be using that

Search through node_modules for AsyncStorage key.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found