Amplify-js: requestPermission called twice with amplify push notifications 1.0.2.

Created on 20 Jul 2018  路  4Comments  路  Source: aws-amplify/amplify-js

Do you want to request a feature or report a bug?
Bug

What is the current behavior?

Initialising the amplify PushNotification class causes error below when asking for permission on IOS.
screen shot 2018-07-20 at 22 45 30

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.

Create new react application with 1.0.2 versions of amplify library. Link PushNotificationIOS libraries, following amplify documentation. Initialise amplify PushNotification with Pinpoint app id.

What is the expected behavior?

Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
1.0.2

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

Push Notifications investigating

Most helpful comment

I also had this issue

The problem was that after I updated Pushnotifications library and amplify I kept the old imports:
import Amplify, { Analytics } from 'aws-amplify';
and called configure on Amplify and PushNotifications;

Amplify.configure(Config);
PushNotification.configure(Config);

I fixed the issue by properly importing the libraries:

import Analytics from '@aws-amplify/analytics';

and configuring Analytics instead of Amplify:

Analytics.configure(Config);
PushNotification.configure(Config);

I think the error happened when both Amplify and PushNotifications tried to call

PushNotification.prototype.initializeIOS

and thus requesting permissions twice

All 4 comments

Same thing happening to me.

same thing

I'm using
"amazon-cognito-identity-js": "^2.0.13",
"aws-amplify": "^1.0.4",
"aws-amplify-react-native": "^1.0.4",
"react": "^16.3.0-alpha.1",
"react-native": "0.54.2",

I also had this issue

The problem was that after I updated Pushnotifications library and amplify I kept the old imports:
import Amplify, { Analytics } from 'aws-amplify';
and called configure on Amplify and PushNotifications;

Amplify.configure(Config);
PushNotification.configure(Config);

I fixed the issue by properly importing the libraries:

import Analytics from '@aws-amplify/analytics';

and configuring Analytics instead of Amplify:

Analytics.configure(Config);
PushNotification.configure(Config);

I think the error happened when both Amplify and PushNotifications tried to call

PushNotification.prototype.initializeIOS

and thus requesting permissions twice

@aris-b This fixes the issue, Amplify docs should be updated to reflect this.

Was this page helpful?
0 / 5 - 0 ratings