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

Add option to default to HMS over FCM #2163

Merged
merged 4 commits into from
Aug 2, 2024
Merged

Add option to default to HMS over FCM #2163

merged 4 commits into from
Aug 2, 2024

Conversation

emawby
Copy link
Contributor

@emawby emawby commented Aug 1, 2024

Description

One Line Summary

Read a manifest metadata boolean to allow apps to prefer HMS over FCM for devices that can receive both.

Details

Apps can add the following to their AndroidManifest.xml
<meta-data android:name="com.onesignal.preferHMS" android:value="true"/>

This setting will allow devices with both HMS and FCM capabilities to use HMS rather than the default of FCM.

I have left in the testing commits for review, but will rebase prior to merge. The only changed file is DeviceService.kt

Motivation

Allows apps to message users who move in and out of zones reachable by FCM, but can always receive HMS.

Scope

subscription type

Testing

Unit testing

n/a

Manual testing

Tested on Huawei device. I have left in 3 testing commits if reviewers would like to test.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

This is migrating over the PR from the player model pr #1984
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks good, just some nits on the code, feel free to ping me again once you add tests.

@@ -37,7 +39,17 @@ internal class DeviceService(private val _applicationService: IApplicationServic
override val deviceType: IDeviceService.DeviceType
get() {
if (supportsADM()) return IDeviceService.DeviceType.Fire
if (supportsGooglePush()) return IDeviceService.DeviceType.Android

val supportsHMS: Boolean = supportsHMS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, we don't need the type, remove : Boolean from here.

val supportsFCM = supportsGooglePush()

if (supportsFCM && supportsHMS) {
val context: Context = _applicationService.appContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, we don't need the type, remove : Context from here.

@emawby emawby requested a review from jkasten2 August 2, 2024 20:19
This creates a new DeviceServiceTests file and moves supportsHMS and supportsGooglePush to the IDeviceService interface
@emawby emawby requested a review from jkasten2 August 2, 2024 21:45
@emawby emawby merged commit f4f30dc into main Aug 2, 2024
2 checks passed
@emawby emawby deleted the add_default_to_huawei branch August 2, 2024 21:54
@jinliu9508 jinliu9508 mentioned this pull request Aug 5, 2024
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

Successfully merging this pull request may close these issues.

3 participants