_From @roblav96 on September 17, 2016 1:59_
I'm not too sure how hard it would be to implement, but having a onNewIntent
event would be awesome.
I'm trying to make a custom url plugin but in order for it to work properly I need to set android:launchMode="singleTask"
on the com.tns.NativeScriptActivity
in AndroidManifest.xml
because if I don't, then the intent launches a whole new instance of my app on top of the already existing one.
I tried this with every android event available:
application.android.on(application.AndroidApplication.activityResumedEvent, function(args: application.AndroidActivityEventData) {
global.tnsconsole.info('application.AndroidApplication.activityResumedEvent >')
let intent: android.content.Intent = args.activity.getIntent()
global.tnsconsole.log('intent.getData()', intent.getData())
global.tnsconsole.log('intent.getDataString()', intent.getDataString())
global.tnsconsole.log('intent.getScheme()', intent.getScheme())
global.tnsconsole.log('intent.getExtras()', intent.getExtras())
})
and they all come up empty.
According to EddyVerbruggen/Custom-URL-scheme, he calls onNewIntent
which is exactely what I'm looking to do. I also tried making my custom activity and overwriting the event, but it doesn't exist in ui/frame/AndroidActivityCallbacks
.
This addition would be greatly appreciated!
_Copied from original issue: NativeScript/android-runtime#558_
import * as application from "application"
import * as frame from "ui/frame"
@JavaProxy('com.tns.NativeScriptActivity')
class Activity extends android.app.Activity {
private _callbacks: frame.AndroidActivityCallbacks
onCreate(savedInstanceState: android.os.Bundle): void {
if (!this._callbacks) {
(<any>frame).setActivityCallbacks(this)
}
this._callbacks.onCreate(this, savedInstanceState, super.onCreate)
}
onNewIntent(intent: android.content.Intent): void {
console.info('onNewIntent', intent)
super.onNewIntent(intent)
}
}
馃嵃
@roblav96 can you show me that code in .js?
Nevermind, i use a site to do that and it seems to work ok. Thanks.
I'm bringing a Cordova App over to NativeScript and I pretty much need to be able to handle open from URL while the app is already running in the background.
roblav's technique above doesn't work, it appears to override some needed functionality in NativeScriptActivity, so seems like I'm stuck unless I can get access to onNewIntent() somehow.
Any update on this one? Why can cordova do this, but it's not working in {N}?
Looking desperately for updates as well. It's been 2 years, please take a look into this.
I'd like to give this feature a go, though I won't be able to do it until mid of October. Any first-timers willing to try?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I'd like to give this feature a go, though I won't be able to do it until mid of October. Any first-timers willing to try?