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
}
});
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.
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.
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.
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:
They are working with Google and Huawei.
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
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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With