push-fcm-plugin icon indicating copy to clipboard operation
push-fcm-plugin copied to clipboard

Push.FCM() returns a pending Promise

Open weiljx opened this issue 8 years ago • 6 comments

First Thanks for all of your effort on this. We have push.js working and are working to get this working with the browser closed through push messaging. Currently when we call

Push.FCM() the promise never returns. It shows the PromiseStatus as "pending". Would be interested if you have any thoughts.

Thanks

weiljx avatar Oct 13 '17 14:10 weiljx

Could you post your code? Are you getting any console errors?

Nickersoft avatar Nov 27 '17 15:11 Nickersoft

I'm getting the same error, the promise stays pending and doesn't seem to return anything

johnjjung avatar Jan 17 '18 15:01 johnjjung

@Nickersoft Not hitting debugger or any console logs below the console.log(config)

// const config = process.env.FIREBASE_CONFIG
    const config = {
      apiKey: process.env.FIREBASE_API_KEY,
      authDomain: process.env.FIREBASE_AUTH_DOMAIN,
      databaseURL: process.env.FIREBASE_DATABASE_URL,
      projectId: process.env.FIREBASE_PROJECT_ID,
      storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
      messagingSenderId: process.env.FIREBASE_MESSAGE_SENDER_ID,
      serviceWorkerLocation: '/static',
      onTokenFetched: (token) => console.log(token)
    }
    console.log(config)
    Push.extend(PushFCM)
    Push.config({
      FCM: config
    })
    Push.FCM().then((fcm) => {
      console.log(fcm)
      debugger
      fcm.getToken().then((token, error) => {
        console.log(token)
        console.log(error)
      }, (error) => { console.log(error) })
      .catch((tokenError) => {
        throw tokenError
      })
    }).catch((initError) => {
      console.log(initError)
      throw initError
    })

johnjjung avatar Jan 17 '18 15:01 johnjjung

Same here. No console log or errors. Testing in latest chrome

otbe avatar Feb 09 '18 08:02 otbe

Got it working. 😄 I used the firebase version of the serviceworker ("firebase-messaging-sw.js") instead of the packaged version from push-fcm-plugin.

otbe avatar Feb 09 '18 10:02 otbe

@otbe can you specify?

So I did the same thing, I copy pasta'd the https://github.com/Nickersoft/push-fcm-plugin/blob/master/firebase-messaging-sw.js into a public directory to get it running, but it still wouldn't work.

Did you change the firebase versioning or something?

johnjjung avatar Feb 09 '18 10:02 johnjjung