question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I'm not getting push notifications from AWS Pinpoint in react native (android) project, onRegister method is never triggered

See original GitHub issue

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

1.My Firebase project configured correctly, I was able to receive push notification from Firebase console 2. I enabled Push notifications in AWS Pinpoint console and added API key and Sender ID there 3. I did these commands in the project: npm install @aws-amplify/pushnotification --save react-native link @aws-amplify/pushnotification

4.Added configuration for analytics and push notifications in App.js

Amplify.configure({
Auth: {
    region: 'xxx',
    userPoolId: 'xxx',
    userPoolWebClientId: 'xxx',
    mandatorySignIn: true
},
API: {
    endpoints: [{
        name: "xxx",
        endpoint: "xxxx",
        custom_header: async () => ({ Authorization: await getAuthorizationToken() })
    }]
},
Analytics: {
  disabled: false,
  AWSPinpoint: {
    appId: 'xxxxxx',
   region: 'us-east-1',
  }
}
});

PushNotification.configure({
 appId: 'xxxx',
 region: 'us-east-1',
 });

5.Added in componentDidMount in App.js method onRegister:

componentDidMount(){
    PushNotification.onRegister((token) => {
        console.log('in app registration', token);
      });
  }

After Sign In added this updateEndpoint method:

Analytics.updateEndpoint({

         address: 'xxxx',
         channelType: 'GCM',
         userId: '1',
     }) 

I was trying to create Test campaign in AWS Pinpoint console, but console didn’t see any devices and didn’t send anything to the phones. PushNotification.onRegister method is never triggered. I can’t get device token. What I’m missing? How to make it work?

Expected behavior Device should receive push notification

Desktop (please complete the following information):

  • OS: Android

Smartphone (please complete the following information):

  • OS: Android

Additional context I’m using AWS Cognito in the project already

Sample code Include additional sample code or a sample repository to help us reproduce the issue. (Be sure to remove any sensitive data)

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.

after adding Amplify.Logger.LOG_LEVEL = ‘DEBUG’; I see this messages:

AWSPinpointProvider - init clients
[DEBUG] 08:46.309 AWSPinpointProvider - no change for aws credentials, directly return from init
[DEBUG] 08:46.312 AWSPinpointProvider - record event with params
[DEBUG] 08:46.314 AWSPinpointProvider - pinpoint put events with params Object {
AWSPinpointProvider - record event success.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
yareyaredesuyocommented, Oct 9, 2019

@saadq

Me too, it works in fireabase console, but not work in pinpoint.

document itself is very obsolete ( https://aws-amplify.github.io/docs/js/push-notifications ).

this does not work (firebase console).

     compile 'com.google.firebase:firebase-core:12.0.1'
     compile 'com.google.firebase:firebase-messaging:12.0.1'

this works (firebase console).

    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation 'com.google.firebase:firebase-messaging:20.0.0'

document is obsolete…, and implementation is blackhole…

so amplify team should make pushnotification’s up to date documents and examples, that works well.

2reactions
Luckygirlllllcommented, Jul 30, 2019

@1pocketaces1 it works like a charm both in Android and IOS, well, as far as I remember it’s free for mobile, I think they charge only for web push notifications and extra features.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm not getting push notifications from AWS Pinpoint in react ...
My Firebase project configured correctly, I was able to receive push notification from Firebase console. I enabled Push notifications in AWS ...
Read more >
Setting up Android Push Notifications with AWS Amplify
In this post, we set up a React Native app using AWS Amplify to receive Android Push Notifications. If you are interested in...
Read more >
Push Notification with Amplify | Sumerian school
When the user opens the app for the first time, the pushed token is fetched and stored in the device. You should be...
Read more >
Frontend Implementation Tips for Pinpoint and AWS Amplify ...
When you start using Amplify for your project, you will be surprised how ... RN 0.64.1; amplify; react-native-push-notification-ios 1.8.0 ...
Read more >
Push Notifications with AWS Amplify - JavaScript Camp
Upload the config file to android / app . · Add Firebase SDK. Consider <project> android and <app-module> app. directory to react native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found