Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Documentation is not enough the call back is never called. #16

Closed
scavezze opened this issue Mar 23, 2017 · 9 comments
Closed

Documentation is not enough the call back is never called. #16

scavezze opened this issue Mar 23, 2017 · 9 comments

Comments

@scavezze
Copy link

I have followed the directions exactly. but the urlHandler never fires. I am running into this issue

NativeScript/NativeScript#3738

i have followed the directions above to cextend the native script activity but It precludes using your handler witch i really like because it helps pars the url and will work on ios. I tried adding

protected onNewIntent(intent: android.content.Intent): void {
	super.onNewIntent(intent) 
        this.setIntent(intent); 
}

instead of

protected onNewIntent(intent: android.content.Intent): void {
	super.onNewIntent(intent)
	if (intent.getDataString) {
		let data = intent.getDataString()
		if (data) {
			console.log('data', data)
		}
	}
}

This solves the issue and i can use your plugin without issue unfortunately this seems to break the ActionBar -> ActionItem click event i am not sure why

have you run into these issues using your plugin? am i missing something. I would really appreciate your help.

@roblav96
Copy link

@scavezze you need to add android:launchMode="singleTask" to your activity in your AndroidManifest.xml. This will certainly resolve your issue. I've had to solve this exact problem before.

@hypery2k
Copy link
Owner

@scavezze Did I need to add the JavaProxy decorator and the extend?
Will try to add it to my plugin if needed

@scavezze
Copy link
Author

scavezze commented Mar 24, 2017

@roblav96 it's already set to single task

<activity
			android:name="com.tns.NativeScriptActivity"
			android:label="@string/title_activity_kimera"
			android:configChanges="keyboardHidden|orientation|screenSize"
			android:theme="@style/LaunchScreenTheme"
			android:launchMode="singleTask"
			android:exported="true" >

I noticed 2 changes were made tho one for the docs and one other one so let me get the latest and try it out

@scavezze
Copy link
Author

@hypery2k I think your really close i have tried whats currently avail and the following line throws a exception

application.android.init(this);

I think don't think you need that and the

protected onNewIntent(intent: android.content.Intent): void {
        super.onNewIntent(intent);
        if (intent.getDataString) {
            handleIntent(intent);
        }
    }

is called every time you receive a external link so i think you just need to remove that line then change handleIntent to something like this

export function handleIntent(intent: any) {
    let data = intent.getData();
    if (data !== lastReceivedData) {
        try {
            if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
				getCallback()(extractAppURL(data));
				lastReceivedData = data;
            }
        } catch (e) {
            console.error('Unknown error during getting App URL data', e);
        }
    }
}

@scavezze
Copy link
Author

scavezze commented Mar 24, 2017

I modified my local version to what i recommended above and it works but again it stops the ActionBar -> ActionItem event from working. gonna try and figure that out .

@scavezze
Copy link
Author

ActionBar -> ActionItem event is not a issue with the linking. I think it's something with when i am changing routes in the handler

@hypery2k
Copy link
Owner

maybe you have to wrap it in a zone

@scavezze
Copy link
Author

@hypery2k

https://gist.github.com/scavezze/28d2e69aa39b69796769d729fc1ee638 with the 0.4.0 version of your plugin works also so i will leave it upto you if you want to change to use protected onNewIntent(intent: android.content.Intent): void { or jsut add it to your documentation.

I am new to Nativescript/Typescript so I will look into zones

hypery2k added a commit that referenced this issue Mar 24, 2017
use event listener and add create event listener, see #16
@scavezze
Copy link
Author

@hypery2k , @roblav96
Thanks for your help i have it all working right now with the 0.4.0 version of your plugin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants