Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't get Firebase token from Huawei p40 series device

I usually get the token with this method, but with the arrival of the huawei p40 series I can't get the token with those

FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( this,  new OnSuccessListener<InstanceIdResult>() {
        @Override
        public void onSuccess(InstanceIdResult instanceIdResult) {
            final String token = instanceIdResult.getToken(); // i can't get this
        }
});
like image 354
Axel López Avatar asked May 05 '20 21:05

Axel López


People also ask

Does firebase work on Huawei?

Cloud Storage Using this SDK, you don't need to change your existing Firebase Realtime Database code. It will start working on Huawei devices and also GMS devices as well.

How do I get firebase tokens from console?

The Firebase console has no feature to show what FCM Instance ID tokens have been handed out. If you want to have listing of all the tokens in your app, you will have to store it yourself. This user is first on the weekly Google Cloud leaderboard.

Where can I find FCM registration token?

Retrieve and store registration tokens As noted in our client setup guides, your app should retrieve this token at initial startup and save it to your app server alongside a timestamp. This timestamp must be implemented by your code and your servers, as it is not provided for you by FCM SDKs.


5 Answers

P40 contains Huawei Mobile Services. These devices don't have Google Mobile Services so Firebase won't work. There is alternative called Push Kit - https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/push-introduction

If you want to make it all working on a one platform, you can try:

  • AirShip (https://docs.airship.com/platform/android/getting-started/#hms).
  • OneSignal (https://documentation.onesignal.com/docs/huawei-sdk-setup).

They are working with Google and Huawei.

like image 137
deadfish Avatar answered Oct 06 '22 00:10

deadfish


As new Huawei phones are banned from using GMS, firebase cannot be used on new Huawei phones. Huawei already provided such notification service, called HMS Push Kit, in order to make push notification available on the devices which don’t have GMS, like mate30, mate30 pro, P40 and any other Huawei new devices. If you want your app to run on these phones, integrate Huawei Push Kit.

Please kindly refer to the links:

Development Guide

Sample Code on Github

like image 31
shirley Avatar answered Sep 22 '22 12:09

shirley


FCM is Firebase cloud Messaging service. New generation of Huawei devices (Huawei P40 series , Mate 30 series,) don't support Google services like Google Map ,FCM, etc. If you want to use your app successfully , your app providers must be integrated HMS service or 3rd party solutions after that You can use related app without any problem.

I think that you can replace it with HMS Push kit or you can use 3rd party push providers. for more information please visit link

like image 38
Serkan M. Avatar answered Oct 05 '22 23:10

Serkan M.


For Flutter projects:

I don't like to use third party like OneSignal to push notifications for many reasons, one of it for example OneSignal not provide way to handle background data in its Flutter plugin like FirebaseMessaging.onBackgroundMessage(...) in firebase_messaging, or Push.registerBackgroundMessageHandler(...) in huawei_push...

So I'm better to use two plugin (in same project):

1- https://pub.dev/packages/firebase_messaging for Android without HMS and IOS...

2- https://pub.dev/packages/huawei_push it work on Android with HMS.

enter image description here

like image 31
AnasSafi Avatar answered Oct 06 '22 00:10

AnasSafi


As new Huawei phones are banned from using GMS, firebase cannot be used on new Huawei phones. Huawei already provided such notification service, called HMS Push Kit, in order to make push notification available on the devices which don’t have GMS, like mate30, mate30 pro, P40 and any other Huawei new devices. If you want your app to run on these phones, integrate Huawei Push Kit.

Please kindly refer to the links:

Development Guide

Sample Code on Github

like image 35
zhangxaochen Avatar answered Oct 06 '22 00:10

zhangxaochen