Skip to content

Does Amplify AWS not generate device token on V6 for Push Notification? #6711

@itmsroohim

Description

@itmsroohim

According to the latest documentation of Aws Amplify V6 ,to generate token we have to use onTokenReceived from aws-amplify/push-notification for implementing push-notifications on Mobile using react-native

const myTokenReceivedHandler = (token) => {
console.log("Push token received in Dashboard:", token);
await identifyUser({
userId: attributes.sub,
options: {
optOut: "NONE",
address: token,
},
});
};

const listener = onTokenReceived(myTokenReceivedHandler);
return () => listener.remove();
}, []);
But this never gets executed,and I donn receive any token . I am using Firebase-messaging/app package to get token and the using identifyUser from aws-amplify/push-notification to register token to endpoint.

const fcmToken = await messaging().getToken();
console.log("FCM token from Firebase:", fcmToken);
await identifyUser({
userId: attributes.sub,
options: {
optOut: "NONE",
address: fcmToken,
},
});
This works and I am getting push-notifications but I want to achieve this using Amplify .It was working fine in V5 but after migrating to V6
I am not able to get tokens
Please suggest what i am doing wrong .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions