CatalystCode / react-native-azurenotificationhub

React Native module to support Azure Notification Hub push notifications on Android, iOS, and Windows.
MIT License
47 stars 75 forks source link

twice before the first has returned (IOS) #116

Closed yasaricli closed 4 years ago

yasaricli commented 4 years ago

I get an error when I try to get permission as follows.

Screen Shot 2020-03-15 at 22 33 47
NotificationHubIos.requestPermissions();

error:

Cannot call requestPermissions twice before the first has returned.

It only happens when ios and 2nd run

Thanks.

phongcao commented 4 years ago

@yasaricli Can you let me know why you need to call requestPermissions method twice? Is it because the first run didn't succeed or you want to request different permissions in the second run?

yasaricli commented 4 years ago

When I run "requestPermissions" every time in version 0.9.0 it doesn't give an error.

Here's an example of how I run it.

import React, { Component } from 'react';
import NotificationHubIos from 'react-native-azurenotificationhub/index.ios';

import Index extends Component {
  componentDidMount() {

    // Maybe an permission check can be done here?

    NotificationHubIos.requestPermissions();
  }

  render() {
    return (
      ...
    )
  }
}

thanks.

yasaricli commented 4 years ago

I'm waiting for this bug. When can you do it @phongcao

Thanks.

phongcao commented 4 years ago

I plan to have a look at this issue in a couple days and it should be resolved with the next release.

phongcao commented 4 years ago

@yasaricli Should be fixed on master branch.

yasaricli commented 4 years ago

thanks @phongcao

yasaricli commented 4 years ago

@phongcao this error continues.

I updated it in v0.9.5 version, it gives error.

phongcao commented 4 years ago

@yasaricli That's strange. I just did some testing again and this issue doesn't seem to occur. Please provide more details/error logs/screenshots if you still see it.

phongcao commented 4 years ago

Make sure you update your App.js as well since there is a lot of changes in 095.

yasaricli commented 4 years ago

there is no problem at first start. But then ctrl + r, or refresh, gets an error.

Screen Shot 2020-03-26 at 19 54 16

Screen Shot 2020-03-26 at 21 17 45
potatoengineer commented 3 years ago

I have this issue as well. Is there a solution? @yasaricli @phongcao

I am currently on "^0.9.5-Patched.1" and using it like such

              <Button
                buttonStyle={styles.button}
                title="Enable Notifications"
                onPress={async () => {
                  await iosNotifications.getInstance().register(true);
                  await dismiss();
                }}
              />