Please provide the following:
- SDK Version: 40
- Platforms(Android/iOS/web/all): all
- Add the appropriate “Tag” based on what Expo library you have a question on.
When the app gets started an async function runs to get and save the notification token. When explicitly blocking notifications, I get an alert (which is good, this tells me the function runs) But when I allow notifications the following needs to be executed:
token = await Notifications.getExpoPushTokenAsync();
fetch('http://xxx.xxx/xxx/xxx.php', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
token: {
value: token,
}
}),
}).then((response) => response.text())
.then((responseData) => {
console.log(responseData);
});
and on that PHP page the only thing that happens is the following:
$json = json_decode(file_get_contents('php://input'), true);
$token = $json['token']['value'];
$sth = $db->prepare('INSERT INTO pushnotificationusers (uid) VALUES (:uid)');
$sth->execute(array(':uid' => $token));
but this doesn’t work. The token isn’t saved. This is both on Android and iOS.
I have Firebase setup and added both Apple’s key and Firebase’s key in Expo.
I really really hope some can help me. Thanks a lot in advance!