title: React-Native OneSignal Android error: OneSignal.init has not been called
body: <p>I'm trying to use the OneSignal react native package to send push notifications to my users. This is working fine for iOS. However, on Android, every call to the <code>OneSignal</code> library times out. When I run <code>adb logcat</code> I see the following message in my console:</p>
  
  <blockquote>
    <p>E/OneSignal: OneSignal.init has not been called. Could not get OSPermissionSubscriptionState</p>
  </blockquote>
  
  <p>According to the documentation (<a href="https://documentation.onesignal.com/v5.0/docs/react-native-sdk-setup" rel="nofollow noreferrer">https://documentation.onesignal.com/v5.0/docs/react-native-sdk-setup</a>), this is not a step I should do manually, but is rather performed by the library itself when setting up the subscription. I have written some helper functions for OneSignal that are throwing the error above:</p>
  
  <pre><code>getPermissionSubscriptionState = () =&gt; {
      return new Promise((resolve, reject) =&gt; {
          OneSignal.getPermissionSubscriptionState((state) =&gt;{
              console.log(state);
              resolve(state);
          });
      });
  }
  
  enablePushnotifications = async () =&gt; {
      OneSignal.registerForPushNotifications();
  }
  
  ensureSubscription = async () =&gt;  {
      const status = await this.getPermissionSubscriptionState();
      console.log(status);
      if(!status.notificationsEnabled &amp;&amp; !status.hasPrompted) {
          this.enablePushnotifications();
      }
      return status;
  }
  </code></pre>
  
  <p>In my root component, I invoke the <code>ensureSubscription</code> method like so: <code>await OneSignalHelper.ensureSubscription();</code>. Inside <code>ensureSubscription()</code> I invoke the <code>getPermissionSubscriptionState()</code>, but as soon as I do that the above error is printed.</p>
  
  <p>Any help would be greatly appreciated.</p>