feat(push): 添加推送通知点击 URL 跳转支持
- 新增 PushDeepLinkHandler:通过 getLaunchIntentForPackage 启动宿主 App 并携带 xuqm_push_url extra,供 MainActivity 读取后导航 WebView - XuqmVivoPushReceiver.onNotificationMessageClicked 提取 params["url"] 或 skipContent,调用 PushDeepLinkHandler.open() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
978312956c
当前提交
f63ae07bcb
@ -0,0 +1,20 @@
|
||||
package com.xuqm.sdk.push
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
|
||||
object PushDeepLinkHandler {
|
||||
|
||||
const val EXTRA_PUSH_URL = "xuqm_push_url"
|
||||
private const val TAG = "PushDeepLinkHandler"
|
||||
|
||||
fun open(context: Context, url: String) {
|
||||
val pm = context.packageManager
|
||||
val intent = pm.getLaunchIntentForPackage(context.packageName) ?: return
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
intent.putExtra(EXTRA_PUSH_URL, url)
|
||||
Log.d(TAG, "Opening app with push URL: $url")
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
package com.xuqm.sdk.push.vivo
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.vivo.push.model.UnvarnishedMessage
|
||||
import com.vivo.push.model.UPSNotificationMessage
|
||||
import com.vivo.push.sdk.OpenClientPushMessageReceiver
|
||||
import com.xuqm.sdk.push.PushDeepLinkHandler
|
||||
import com.xuqm.sdk.push.PushSDK
|
||||
import com.xuqm.sdk.push.model.PushVendor
|
||||
|
||||
@ -25,7 +27,12 @@ class XuqmVivoPushReceiver : OpenClientPushMessageReceiver() {
|
||||
}
|
||||
|
||||
override fun onNotificationMessageClicked(context: Context, message: UPSNotificationMessage) {
|
||||
Log.d(TAG, "Vivo notification clicked: ${message.title}")
|
||||
val url = message.params?.get("url")?.takeIf { it.isNotBlank() }
|
||||
?: message.skipContent?.takeIf { it.isNotBlank() }
|
||||
Log.d(TAG, "Vivo notification clicked: ${message.title}, url=$url")
|
||||
if (url != null) {
|
||||
PushDeepLinkHandler.open(context, url)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户