Skip to content

Commit f2848de

Browse files
committed
Add logic for preferring HMS over FCM for devices that support both
1 parent 1d27d82 commit f2848de

File tree

1 file changed

+10
-2
lines changed
  • OneSignalSDK/onesignal/src/main/java/com/onesignal

1 file changed

+10
-2
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSUtils.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,19 @@ int getDeviceType() {
369369
if (supportsADM())
370370
return UserState.DEVICE_TYPE_FIREOS;
371371

372-
if (supportsGooglePush())
372+
boolean preferHMS = false;
373+
boolean supportsHMS = supportsHMS();
374+
boolean supportsFCM = supportsGooglePush();
375+
376+
if (supportsFCM && supportsHMS) {
377+
return preferHMS ? UserState.DEVICE_TYPE_HUAWEI: UserState.DEVICE_TYPE_ANDROID;
378+
}
379+
380+
if (supportsFCM)
373381
return UserState.DEVICE_TYPE_ANDROID;
374382

375383
// Some Huawei devices have both FCM & HMS support, but prefer FCM (Google push) over HMS
376-
if (supportsHMS())
384+
if (supportsHMS)
377385
return UserState.DEVICE_TYPE_HUAWEI;
378386

379387
// Start - Fallback logic

0 commit comments

Comments
 (0)