Hi there,
I hope you could help me, from days this issue is driving me crazy.
I have an android app build with Expo, my server is written in Ruby. This one is responsible to send a notification to OP each time someone comment his post.
It working well locally. But when I am dealing with the beta version none notifications is displayed. It sounds that all notifications are sent, but never displayed.
But if I use the notifications tools test made by Expo, it works !
Below my code server-side;
class PushNotificationService
attr_reader :title, :user_id
include HTTParty
def initialize(args)
@title = args[:title]
@user_id = args[:user_id]
end
def call
expo_token = ExpoToken.find_by(user_id: user_id)
return if expo_token.nil?
HTTParty.post(
'https://exp.host/--/api/v2/push/send',
body: {
'to' => expo_token.token,
'title' => title
}
)
end
end
My client-side
export default registerForNotifications = async (token) => {
const { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
return;
}
}
const expoToken = await Notifications.getExpoPushTokenAsync();
fetch(PUSH_ENDPOINT, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip, deflate',
},
body: JSON.stringify({
expo_token: expoToken,
token: token,
}),
});
};
I have another app published on PlayStore, I reused exactly the same code and notifications works well. But it was written with Expo SDK 32.
I guess a lot of things change between 32 and 37, but why it works well locally ? And why it works with the Expo notification test tools ?
Any help will be really appreciate.
Thanks.