Repository navigation
|
Hello everyone, We're trying to achieve a specific behavior on Android (currently) and IOS for our React Native app: Goal: Redirect users directly from an Mindbox (via FCM) push notification to a Telegram channel (or browser as fallback) without our React Native app launching/appearing. What we've tried:
Problem: Question: Thanks! |
Replies: 1 comment
|
Hi! Sorry for the late reply, and thanks for the detailed description. Short answer: on Android you can open Telegram without your app ever showing up. On iOS this is not possible, but you can redirect immediately so the app is barely visible. AndroidYou don't need your own notification for this. Keep Mindbox showing the push, and send Mindbox.handleRemoteMessage(
context, message, channelId, channelName, pushSmallIcon,
defaultActivity = MainActivity::class.java,
activities = mapOf("https://t.me/*" to ExternalLinkActivity::class.java),
)<activity
android:name=".ExternalLinkActivity"
android:exported="false"
android:taskAffinity=""
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />class ExternalLinkActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Mindbox.onPushClicked(this, intent)
Mindbox.getUrlFromPushIntent(intent)?.let { url ->
runCatching {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
}
}
finish()
}
}Because of its empty If iOSOn iOS, tapping a notification always opens the app that owns it. Apple provides no way to open another app straight from a notification or its action buttons. The best you can do is redirect as early as possible, natively in func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
Mindbox.shared.pushClicked(response: response)
let userInfo = response.notification.request.content.userInfo
if let link = Mindbox.shared.getMindboxPushData(userInfo: userInfo)?.clickUrl,
link.hasPrefix("https://t.me/"),
let url = URL(string: link) {
UIApplication.shared.open(url)
}
completionHandler()
}Hope this helps! |
Hi! Sorry for the late reply, and thanks for the detailed description.
Short answer: on Android you can open Telegram without your app ever showing up. On iOS this is not possible, but you can redirect immediately so the app is barely visible.
Android
You don't need your own notification for this. Keep Mindbox showing the push, and send
t.melinks to a lightweight transparent activity using theactivitiesparameter ofMindbox.handleRemoteMessage(URL mask → Activity class). That activity opens the link and closes immediately, soMainActivityand the React Native bridge are never started.Mindbox.handleRemoteMessage( context, message, channelId, channelName, pushSmallIcon, defaultA…