Skip to content

Commit

Permalink
Merge pull request #85 from Notificare/release/3.5.3
Browse files Browse the repository at this point in the history
3.5.3
  • Loading branch information
hpinhal committed Jun 16, 2023
2 parents d434590 + 42f4012 commit 12d15ed
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

- ## 3.5.3

- Explicit handling of Notificare Links in Deep Link notifications
- Improve supported deep links validation
- Stricter unlaunch flow

## 3.5.2

- Prevent multiple configurations from taking place
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ internal object NotificareGeoImpl : NotificareModule(), NotificareGeo, Notificar
}
}

override suspend fun unlaunch() {
localStorage.locationServicesEnabled = false

clearRegions()
clearBeacons()

lastKnownLocation = null
serviceManager?.disableLocationUpdates()

clearLocation()
}

// endregion

// region Notificare Geo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ internal object NotificareInboxImpl : NotificareModule(), NotificareInbox {

override suspend fun unlaunch() {
clearLocalInbox()
clearNotificationCenter()
clearRemoteInbox()
}

// endregion
Expand Down Expand Up @@ -416,4 +418,13 @@ internal object NotificareInboxImpl : NotificareModule(), NotificareInbox {
NotificationManagerCompat.from(Notificare.requireContext())
.cancelAll()
}

private suspend fun clearRemoteInbox() = withContext(Dispatchers.IO) {
val device = Notificare.device().currentDevice
?: throw NotificareDeviceUnavailableException()

NotificareRequest.Builder()
.delete("/notification/inbox/fordevice/${device.id}", null)
.response()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ internal object NotificareLoyaltyImpl : NotificareModule(), NotificareLoyalty, N

override suspend fun unlaunch() {
Notificare.removeListener(this)

passesBySerial.values.forEach { endPassRelevance(it) }
database.passes().clear()
}

// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ internal object NotificareMonetizeImpl : NotificareModule(), NotificareMonetize,
override suspend fun unlaunch() {
checkNotNull(serviceManager) { "No monetize dependencies have been detected. Please include one of the platform-specific monetize packages." }
.stopConnection()

database.purchases().clear()

_observableProducts.postValue(listOf())
_observablePurchases.postValue(listOf())
}

// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ internal interface PurchasesDao {

@Query("SELECT * FROM purchases")
fun getObservablePurchases(): LiveData<List<PurchaseEntity>>

@Query("DELETE FROM purchases")
suspend fun clear()
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,45 @@ internal object NotificarePushUIImpl : NotificareModule(), NotificarePushUI, Not
return
}

val intent = Intent(Intent.ACTION_VIEW, Uri.parse(content.data as String)).apply {
val url = Uri.parse(content.data as String)
if (url.host?.endsWith("ntc.re") != true) {
presentDeepLink(activity, notification, url)
return
}

Notificare.coroutineScope.launch {
try {
val link = Notificare.fetchDynamicLink(url)
presentDeepLink(activity, notification, Uri.parse(link.target))
} catch (e: Exception) {
onMainThread {
lifecycleListeners.forEach { it.onNotificationFailedToPresent(notification) }
}
}
}
}

private fun presentDeepLink(activity: Activity, notification: NotificareNotification, url: Uri) {
val intent = Intent(Intent.ACTION_VIEW, url).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
setPackage(activity.applicationContext.packageName)
}

// Check if the application can handle the intent itself.
if (intent.resolveActivity(activity.applicationContext.packageManager) != null) {
activity.startActivity(intent)

onMainThread {
lifecycleListeners.forEach { it.onNotificationPresented(notification) }
}
} else {
if (intent.resolveActivity(activity.applicationContext.packageManager) == null) {
NotificareLogger.warning("Cannot open a deep link that's not supported by the application.")

onMainThread {
lifecycleListeners.forEach { it.onNotificationFailedToPresent(notification) }
}

return
}

activity.startActivity(intent)

onMainThread {
lifecycleListeners.forEach { it.onNotificationPresented(notification) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ internal object NotificarePushImpl : NotificareModule(), NotificarePush, Notific
}

override suspend fun unlaunch() {
// TODO check if we need to disable remote notifications
sharedPreferences.remoteNotificationsEnabled = false
sharedPreferences.firstRegistration = true

// Update the local notification settings.
// Registering a temporary device automatically reports the allowedUI to the API.
allowedUI = false
}

// endregion
Expand Down
6 changes: 3 additions & 3 deletions notificare/src/main/java/re/notifica/Notificare.kt
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ public object Notificare {

Notificare.coroutineScope.launch {
try {
NotificareLogger.debug("Registering a temporary device.")
deviceImplementation().registerTemporary()

// Loop all possible modules and un-launch the available ones.
NotificareModule.Module.values().reversed().forEach { module ->
module.instance?.run {
Expand All @@ -230,6 +227,9 @@ public object Notificare {
NotificareLogger.debug("Clearing device tags.")
device().clearTags()

NotificareLogger.debug("Registering a temporary device.")
deviceImplementation().registerTemporary()

NotificareLogger.debug("Removing device.")
deviceImplementation().delete()

Expand Down
2 changes: 1 addition & 1 deletion notificare/src/main/java/re/notifica/internal/Version.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package re.notifica.internal

internal const val NOTIFICARE_VERSION = "3.5.2"
internal const val NOTIFICARE_VERSION = "3.5.3"
26 changes: 2 additions & 24 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="re.notifica" />
<data android:scheme="re.notifica.sample.app" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
Expand All @@ -56,7 +56,7 @@
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="hallo.ntc.re"
android:host="sample.ntc.re"
android:scheme="https" />
</intent-filter>
<intent-filter android:autoVerify="true">
Expand All @@ -70,28 +70,6 @@
android:pathPrefix="/testdevice"
android:scheme="https" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="${notificareApplicationId}.applinks.notifica.re"
android:pathPrefix="/oauth/validate"
android:scheme="https" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="${notificareApplicationId}.applinks.notifica.re"
android:pathPrefix="/oauth/resetpassword"
android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".ui.inbox.InboxActivity"
Expand Down
2 changes: 1 addition & 1 deletion variables.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {

// Maven
maven_artifact_group = 're.notifica'
maven_artifact_version = '3.5.2'
maven_artifact_version = '3.5.3'
aws_s3_access_key_id = System.env.AWS_ACCESS_KEY_ID ?: properties.getProperty('aws.s3.access_key_id')
aws_s3_secret_access_key = System.env.AWS_SECRET_ACCESS_KEY ?: properties.getProperty('aws.s3.secret_access_key')

Expand Down

0 comments on commit 12d15ed

Please sign in to comment.