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

Fix: Notification click not foreground the app in the first click if app is closed and no clickListener is added #2259

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.onesignal.core.internal.startup

import com.onesignal.OneSignal
import com.onesignal.core.internal.application.IApplicationService
import com.onesignal.core.internal.config.ConfigModel
import com.onesignal.core.internal.config.ConfigModelStore

/**
* Implement and provide this interface as part of service registration to indicate the service
* wants to be instantiated and its [bootstrap] function called during the initialization process.
*
* When [IBootstrapService.bootstrap] is called, only [OneSignal.setAppId] have been called during
* [OneSignal.initWithContext].
*
* This means the following is true:
*
* 1) An appContext is available in [IApplicationService.appContext].
* 2) An appId is available in [ConfigModel.appId] via [ConfigModelStore.get]
* 3) None of the [IStartableService.start] is called
*
* When bootstrap there is no guarantee that any other data is available. Typically a bootstrap service
* must be instantiated immediately and will add their appropriate hooks to then respond to changes
* in the system.
*/
interface IBootstrapService {
/**
* Called when the service is to be bootstrap. The appId and appContext have already been established.
*/

fun bootstrap()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import com.onesignal.core.internal.config.ConfigModelStore
* 1) An appContext is available in [IApplicationService.appContext].
* 2) An appId is available in [ConfigModel.appId] via [ConfigModelStore.get]
*
* When started there is no guarantee that any other data is available. Typically a startable service
* must be instantiated immediately and will add their appropriate hooks to then respond to changes
* in the system.
* When started there is no guarantee that any other data is available. Typically a startable service
* can asynchronously start some lengthy process that doesn't require immediate use.
*/
interface IStartableService {
/**
Expand All @@ -26,11 +25,3 @@ interface IStartableService {
*/
fun start()
}

internal interface IBootstrapService {
/**
* Called when the service is to be started. The appId and appContext have already been
* established.
*/
fun bootstrap()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.onesignal.inAppMessages
import android.os.Build
import com.onesignal.common.modules.IModule
import com.onesignal.common.services.ServiceBuilder
import com.onesignal.core.internal.startup.IBootstrapService
import com.onesignal.core.internal.startup.IStartableService
import com.onesignal.inAppMessages.internal.DummyInAppMessagesManager
import com.onesignal.inAppMessages.internal.InAppMessagesManager
Expand Down Expand Up @@ -50,7 +51,7 @@ internal class InAppMessagesModule : IModule {
builder.register<InAppDisplayer>().provides<IInAppDisplayer>()

// Previews
builder.register<InAppMessagePreviewHandler>().provides<IStartableService>()
builder.register<InAppMessagePreviewHandler>().provides<IBootstrapService>()

// Prompts
builder.register<InAppMessagePromptFactory>().provides<IInAppMessagePromptFactory>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.onesignal.inAppMessages.internal.preview

import android.app.Activity
import com.onesignal.core.internal.application.IApplicationService
import com.onesignal.core.internal.startup.IStartableService
import com.onesignal.core.internal.startup.IBootstrapService
import com.onesignal.core.internal.time.ITime
import com.onesignal.inAppMessages.internal.display.IInAppDisplayer
import com.onesignal.inAppMessages.internal.state.InAppStateService
Expand All @@ -25,8 +25,8 @@ internal class InAppMessagePreviewHandler(
private val _notificationLifeCycle: INotificationLifecycleService,
private val _state: InAppStateService,
private val _time: ITime,
) : IStartableService, INotificationLifecycleCallback {
override fun start() {
) : IBootstrapService, INotificationLifecycleCallback {
override fun bootstrap() {
_notificationLifeCycle.setInternalNotificationLifecycleCallback(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ internal class NotificationLifecycleService(
activity: Activity,
data: JSONObject,
): Boolean {
var canOpen = extOpenedCallback.hasSubscribers
var canOpen = true
intLifecycleCallback.suspendingFire { canOpen = it.canOpenNotification(activity, data) }
return canOpen
}
Expand Down
Loading