{"action":"created","issue":{"url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1271","repository_url":"https://api.github.com/repos/invertase/react-native-firebase","labels_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1271/labels{/name}","comments_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1271/comments","events_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1271/events","html_url":"https://github.com/invertase/react-native-firebase/issues/1271","id":338009921,"node_id":"MDU6SXNzdWUzMzgwMDk5MjE=","number":1271,"title":"onTokenRefresh being called every time the app loads","user":{"login":"amanthegreatone","id":24354452,"node_id":"MDQ6VXNlcjI0MzU0NDUy","avatar_url":"https://avatars3.githubusercontent.com/u/24354452?v=4","gravatar_id":"","url":"https://api.github.com/users/amanthegreatone","html_url":"https://github.com/amanthegreatone","followers_url":"https://api.github.com/users/amanthegreatone/followers","following_url":"https://api.github.com/users/amanthegreatone/following{/other_user}","gists_url":"https://api.github.com/users/amanthegreatone/gists{/gist_id}","starred_url":"https://api.github.com/users/amanthegreatone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amanthegreatone/subscriptions","organizations_url":"https://api.github.com/users/amanthegreatone/orgs","repos_url":"https://api.github.com/users/amanthegreatone/repos","events_url":"https://api.github.com/users/amanthegreatone/events{/privacy}","received_events_url":"https://api.github.com/users/amanthegreatone/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"Salakar","id":5347038,"node_id":"MDQ6VXNlcjUzNDcwMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/5347038?v=4","gravatar_id":"","url":"https://api.github.com/users/Salakar","html_url":"https://github.com/Salakar","followers_url":"https://api.github.com/users/Salakar/followers","following_url":"https://api.github.com/users/Salakar/following{/other_user}","gists_url":"https://api.github.com/users/Salakar/gists{/gist_id}","starred_url":"https://api.github.com/users/Salakar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Salakar/subscriptions","organizations_url":"https://api.github.com/users/Salakar/orgs","repos_url":"https://api.github.com/users/Salakar/repos","events_url":"https://api.github.com/users/Salakar/events{/privacy}","received_events_url":"https://api.github.com/users/Salakar/received_events","type":"User","site_admin":false},"assignees":[{"login":"Salakar","id":5347038,"node_id":"MDQ6VXNlcjUzNDcwMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/5347038?v=4","gravatar_id":"","url":"https://api.github.com/users/Salakar","html_url":"https://github.com/Salakar","followers_url":"https://api.github.com/users/Salakar/followers","following_url":"https://api.github.com/users/Salakar/following{/other_user}","gists_url":"https://api.github.com/users/Salakar/gists{/gist_id}","starred_url":"https://api.github.com/users/Salakar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Salakar/subscriptions","organizations_url":"https://api.github.com/users/Salakar/orgs","repos_url":"https://api.github.com/users/Salakar/repos","events_url":"https://api.github.com/users/Salakar/events{/privacy}","received_events_url":"https://api.github.com/users/Salakar/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-07-03T18:30:55Z","updated_at":"2018-07-07T17:16:36Z","closed_at":null,"author_association":"NONE","body":"### Issue\r\nEvery time the app loads onTokenRefresh is getting called. Seeing this on iOS simulator as of now. Will update if its the case with real devices also.\r\n\r\nAppContainer.js\r\n```\r\nclass AppContainer extends Component {\r\ncomponentDidMount() {\r\n    createAndroidNotificationChannel()\r\n    this.attachFirebaseListeners()\r\n}\r\n\r\ncomponentWillUnmount() {\r\n    this.fcmMessageListener()\r\n    this.notificationListener()\r\n    this.notificationDisplayedListener()\r\n    this.notificationOpenedListener()\r\n    this.onTokenRefreshListener()\r\n}\r\n\r\nattachFirebaseListeners = async () => {\r\n    try {\r\n\t    this.onTokenRefreshListener = firebase.messaging().onTokenRefresh(fcmToken => {\r\n                console.log('fcm onTokenRefresh: this seems to be a bug as this method is being called every time app loads')\r\n\t           // TODO: send the new token to server\r\n\t     })\r\n\r\n            this.fcmMessageListener = firebase.messaging().onMessage(message => {\r\n\t\t    console.log('onMessage:', message)\r\n\t    })\r\n\r\n\t    const notificationOpen = await firebase.notifications().getInitialNotification()\r\n\t    if (notificationOpen) {\r\n\t\t    console.log('getInitialNotification:', notificationOpen)\r\n\t    }\r\n\r\n\t    this.notificationListener = firebase.notifications().onNotification(notification => {\r\n\t\t    console.log('onNotification:', notification)\r\n\t    })\r\n\r\n\t    this.notificationOpenedListener = firebase.notifications().onNotificationOpened(notificationOpen => {\r\n\t\t    console.log('onNotificationOpened:', notificationOpen)\r\n\t    })\r\n\r\n\t    this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed(notification => {\r\n\t\t    console.log('onNotificationDisplayed:', notification)\r\n\t    })\r\n    } catch (error) {\r\n\t    console.log(error)\r\n    }\r\n}\r\n\r\nrender() {\r\n\tconst signedIn = this.props.userSession && this.props.userSession.token && this.props.subdomainConfig.baseURL ? true : false\r\n\tconst Layout = rootNavigator(signedIn)\r\n         return <Layout />\r\n\t}\r\n}\r\n\r\nconst mapDispatchToProps = dispatch => bindActionCreators(ActionCreators, dispatch)\r\nconst mapStateToProps = ({ userSession, subdomainConfig }) => ({ userSession, subdomainConfig})\r\nexport default connect(mapStateToProps,mapDispatchToProps)(AppContainer)\r\n```\r\n\r\n### Environment\r\n\r\nApplication Target Platform: iOS\r\nDevelopment Operating System: macOS High Seirra\r\nBuild Tools: XCode 9.4\r\nReact Native version: 0.54.2\r\nReact Native Firebase Version: 4.2.0\r\nFirebase Module: Messaging and Notifications\r\nAre you using typescript? No\r\n"},"comment":{"url":"https://api.github.com/repos/invertase/react-native-firebase/issues/comments/403230394","html_url":"https://github.com/invertase/react-native-firebase/issues/1271#issuecomment-403230394","issue_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1271","id":403230394,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzIzMDM5NA==","user":{"login":"amanthegreatone","id":24354452,"node_id":"MDQ6VXNlcjI0MzU0NDUy","avatar_url":"https://avatars3.githubusercontent.com/u/24354452?v=4","gravatar_id":"","url":"https://api.github.com/users/amanthegreatone","html_url":"https://github.com/amanthegreatone","followers_url":"https://api.github.com/users/amanthegreatone/followers","following_url":"https://api.github.com/users/amanthegreatone/following{/other_user}","gists_url":"https://api.github.com/users/amanthegreatone/gists{/gist_id}","starred_url":"https://api.github.com/users/amanthegreatone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amanthegreatone/subscriptions","organizations_url":"https://api.github.com/users/amanthegreatone/orgs","repos_url":"https://api.github.com/users/amanthegreatone/repos","events_url":"https://api.github.com/users/amanthegreatone/events{/privacy}","received_events_url":"https://api.github.com/users/amanthegreatone/received_events","type":"User","site_admin":false},"created_at":"2018-07-07T17:16:36Z","updated_at":"2018-07-07T17:16:36Z","author_association":"NONE","body":"that is how i am restricting redundant calls to send the token to my server yes. but i dont think this is intended behaviour. or is it?"}}
{"actor":{"display_login":"amanthegreatone"}}