Add Link Activity

This commit is contained in:
sim 2024-10-28 08:18:40 +00:00
parent 5f314e35e0
commit 5d6b3b887d
3 changed files with 36 additions and 0 deletions

View File

@ -39,6 +39,16 @@
android:theme="@style/Theme.NextPush.NoActionBar">
</activity>
<activity android:name=".activities.LinkActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="unifiedpush"
android:host="link" />
</intent-filter>
</activity>
<service
android:name=".services.StartService"
android:enabled="true"

View File

@ -0,0 +1,25 @@
package org.unifiedpush.distributor.nextpush.activities
import android.app.Activity
import android.app.PendingIntent
import android.content.Intent
import android.os.Bundle
import android.util.Log
import org.unifiedpush.distributor.nextpush.distributor.EXTRA_PI
class LinkActivity: Activity() {
private val TAG = LinkActivity::class.simpleName
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.run {
Log.d(TAG, "Received request for $callingPackage")
val intent = Intent("org.unifiedpush.register.dummy_app")
val pendingIntent = PendingIntent.getBroadcast(this@LinkActivity, 0, intent, PendingIntent.FLAG_IMMUTABLE)
val result = Intent().apply {
putExtra(EXTRA_PI, pendingIntent)
}
setResult(RESULT_OK, result)
} ?: setResult(RESULT_CANCELED)
finish()
}
}

View File

@ -14,6 +14,7 @@ const val ACTION_REGISTER = "org.unifiedpush.android.distributor.REGISTER"
const val ACTION_UNREGISTER = "org.unifiedpush.android.distributor.UNREGISTER"
const val EXTRA_APPLICATION = "application"
const val EXTRA_PI = "pi"
const val EXTRA_TOKEN = "token"
const val EXTRA_ENDPOINT = "endpoint"
const val EXTRA_MESSAGE = "message"