Skip to content
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

firebase cloud messaging works on iOS simulator but doesn't works on real device #1596

Closed
heeroduo opened this issue Oct 15, 2018 · 3 comments
Labels
Type: Stale Issue has become stale - automatically added by Stale bot

Comments

@heeroduo
Copy link

heeroduo commented Oct 15, 2018

Issue

It's my code. As you can see that it's simple code for test cloud message.
When the device receive any message, it will show a simple alert box.
And it worked well in iOS simulator. the simulator as iPhone 8 plus, iOS 11.4 ver.
When I send some message in Firebase console, it shows the alert box immediately.
And my real test device is also iPhone 8 plus and the iOS version is also 11.4
But when I send same message, this real device doesn't show the alert box.
And also it doesn't trigger onMessage.

It has same codes and same setting. I checked about notification setting in the device.
But it's allowed notifications. And also checked about permission and token. The device
got permission and token correctly without any problems and I can read the token.

'FCM does not work on the iOS simulator, you must test them using a real device.
This is a restriction enforced by Apple.' I read it in official document but actually it works...
I don't know why it actually works in simulator but not a real device. If it didn't work on
simulator, I tried to find some other problems but it works on simulator. So maybe there
is some other kind of problem I think.

componentDidMount() {
firebase.messaging().hasPermission()
.then(enabled => {
if (enabled) {
this.setState({testState: 'enabled'});
} else {
firebase.messaging().requestPermission()
.then(() => {
this.setState({testState: 'requested'});
})
.catch(error => {
this.setState({testState: 'error'});
});
}
});
this.messageListener = firebase.messaging().onMessage((message: RemoteMessage) => {
Alert.alert('test', 'message');
});
}

componentWillUnmount() {
this.onTokenRefreshListener();
this.messageListener();
}

Environment

  1. Application Target Platform:

iOS (11.4 version)

  1. Development Operating System:

macOC

  1. Build Tools:

Xcode

  1. React Native version:

0.56.0

  1. React Native Firebase Version:

5.0.0

  1. Firebase Module:

messaging(5.9 ver)

  1. Are you using typescript?

no

  1. Test device

iPhone 8 plus

@stale
Copy link

stale bot commented Nov 12, 2018

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Nov 12, 2018
@stale
Copy link

stale bot commented Nov 26, 2018

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Nov 26, 2018
@tarr11
Copy link

tarr11 commented Jan 6, 2019

Take a look at #1374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Stale Issue has become stale - automatically added by Stale bot
Projects
None yet
Development

No branches or pull requests

2 participants