Amplify-js: react-native PushNotification.onRegister called twice on Android

Created on 27 Jun 2018  路  3Comments  路  Source: aws-amplify/amplify-js

PushNotification.onRegister is called twice on android causing duplicate endpoints in Pinpoint segment. This bug causes duplicate push notifications sent to android devices.

Code:

import Amplify from 'aws-amplify';
import { PushNotification } from 'aws-amplify-react-native';
import aws_exports from '../aws-exports';

// PushNotification need to work with Analytics
Amplify.configure(aws_exports);
PushNotification.configure(aws_exports);

// get the notification data
PushNotification.onNotification((notification) => {
    // Note that the notification object structure is different from Android and IOS
    console.log('in app notification', notification);

    if(Platform.OS === 'ios') {
        notification.finish(PushNotificationIOS.FetchResult.NoData);
    }

});

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

Console output:
{[DEBUG] 56:04.895 Notification - update endpoint in push notification: "d-BxWr2r6sU:APA91bHyoJ7bocoq4KeF3wyBIM8XQwMIGSTgt8鈥737-LwwpzEvSTDL6cdyuS1n9XOwhuLKatDv7gFblh2u-h9Ig"}
in app registration d-BxWr2r6sU:APA91bHyoJ7bocoq4KeF3wyBIM8XQwMIGSTgt8TZOy58gbCingQeDjue3EHton2krKhwY_HFpUsvgAQk8HodbJIkx5oGq9de42fLn3nPHV92YVWTBT737-LwwpzEvSTDL6cdyuS1n9XOwhuLKatDv7gFblh2u-h9Ig
{[DEBUG] 56:04.962 Notification - update endpoint in push notification: "d-BxWr2r6sU:APA91bHyoJ7bocoq4KeF3wyBIM8XQwMIGSTgt8鈥737-LwwpzEvSTDL6cdyuS1n9XOwhuLKatDv7gFblh2u-h9Ig"}[DEBUG] 56:04.962 Notification - update endpoint in push notification: "d-BxWr2r6sU:APA91bHyoJ7bocoq4KeF3wyBIM8XQwMIGSTgt8TZOy58gbCingQeDjue3EHton2krKhwY_HFpUsvgAQk8HodbJIkx5oGq9de42fLn3nPHV92YVWTBT737-LwwpzEvSTDL6cdyuS1n9XOwhuLKatDv7gFblh2u-h9Ig"__proto__: Object
in app registration d-BxWr2r6sU:APA91bHyoJ7bocoq4KeF3wyBIM8XQwMIGSTgt8TZOy58gbCingQeDjue3EHton2krKhwY_HFpUsvgAQk8HodbJIkx5oGq9de42fLn3nPHV92YVWTBT737-LwwpzEvSTDL6cdyuS1n9XOwhuLKatDv7gFblh2u-h9Ig

Push Notifications investigating

Most helpful comment

I had to remove
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

from AndroidManifest.xml

All 3 comments

This issue should be fixed per this merge: #1428

I had to remove
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

from AndroidManifest.xml

@abhaykumar1415
worked for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josoroma picture josoroma  路  3Comments

epicfaace picture epicfaace  路  3Comments

callmekatootie picture callmekatootie  路  3Comments

karlmosenbacher picture karlmosenbacher  路  3Comments

cosmosof picture cosmosof  路  3Comments