Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning #126

Open
simonj82 opened this issue Sep 14, 2018 · 1 comment
Open

UnhandledPromiseRejectionWarning #126

simonj82 opened this issue Sep 14, 2018 · 1 comment

Comments

@simonj82
Copy link

simonj82 commented Sep 14, 2018

Hi,
i'm trying to use your plugin with Ionic 4.
This is my app.component.ts file content:


import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { TabsPage } from '../pages/tabs/tabs';

declare var cordova:any;

@Component({
  templateUrl: 'app.html'
})
export class MyApp {

  rootPage:any = TabsPage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });

    cordova.plugins.ParsePushPlugin.getInstallationId(function (id) {
      cordova.plugins.ParsePushPlugin.on('receivePN', function (pn) {
        console.log(pn);
      });
    });
  }
}

When I'm going to compile for iOS i've this output:

(node:27894) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27894) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

But sometimes (I don't know why) it passes through that error, compile successfully for iOS and push notifications works perfectly.

Could you help me?

@ghenry22
Copy link

ghenry22 commented Oct 6, 2018

Move your code calling the parsepush plugin to be on a new line immediately below the splashscreen.hide. You need to wait for platform.ready to fire before calling any Cordova plugins.

The way you have it now it isn’t waiting for platform.ready so if you call it too early it will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants