-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from Notificare/release/3.10.0
3.10.0
- Loading branch information
Showing
9 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
notificare-push-ui/src/main/java/re/notifica/push/ui/internal/NotificationUrlResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package re.notifica.push.ui.internal | ||
|
||
import android.net.Uri | ||
import re.notifica.models.NotificareNotification | ||
|
||
internal object NotificationUrlResolver { | ||
|
||
internal fun resolve(notification: NotificareNotification): UrlResolverResult { | ||
val content = notification.content.firstOrNull { it.type == "re.notifica.content.URL" } | ||
?: return UrlResolverResult.NONE | ||
|
||
val urlStr = content.data as? String | ||
if (urlStr.isNullOrBlank()) return UrlResolverResult.NONE | ||
|
||
val url = Uri.parse(urlStr) | ||
val isHttpUrl = url.scheme == "http" || url.scheme == "https" | ||
val isDynamicLink = url.host?.endsWith("ntc.re") == true | ||
|
||
if (!isHttpUrl || isDynamicLink) return UrlResolverResult.URL_SCHEME | ||
|
||
val webViewQueryParameter = url.getQueryParameter("notificareWebView") | ||
val isWebViewMode = webViewQueryParameter == "1" || webViewQueryParameter?.lowercase() == "true" | ||
|
||
return if (isWebViewMode) UrlResolverResult.WEB_VIEW else UrlResolverResult.IN_APP_BROWSER | ||
} | ||
|
||
internal enum class UrlResolverResult { | ||
NONE, | ||
URL_SCHEME, | ||
IN_APP_BROWSER, | ||
WEB_VIEW, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
notificare-push-ui/src/main/java/re/notifica/push/ui/utils/Uri.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package re.notifica.push.ui.utils | ||
|
||
import android.net.Uri | ||
|
||
internal fun Uri.Builder.removeQueryParameter(key: String): Uri.Builder { | ||
val uri = this.build() | ||
|
||
this.clearQuery() | ||
|
||
for (param in uri.queryParameterNames) { | ||
if (param == key) continue | ||
|
||
val value = uri.getQueryParameter(param) | ||
this.appendQueryParameter(param, value) | ||
} | ||
|
||
return this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package re.notifica.internal | ||
|
||
internal const val NOTIFICARE_VERSION = "3.9.1" | ||
internal const val NOTIFICARE_VERSION = "3.10.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters