Application is open, but Won't go to callback
When the app is already opened in the background and i click the link its goes there with all the right details, but when the app is closed and i click the link the app will open, but as if i opened it regulary, without reaching the callback
When thee app is already opened in the background and i cick the link its goes there with all the right details, but when the app is closed and i click the link the app will open, but as if i opened it regulary, without reaching the callback
I have been facing same issue. when app is open in background , everything works perfect but when we kill the app and tried to open from the link. it just opens the app but won't do the callback.
Same here, callback won't hit for iOS app. For Android works fine though.
This is an error I was facing as well. My problem was related to a custom delegate we had created to handle a custom event not yet supported by Nativescript. Commenting out the custom delegate, actually fixed the issue and I can get the callback on iOS as well.
Thanks for sharing that @ArsenTabaku will check my app for such custom events too.
I am having the same error where my application opens from a universal link, but the function registerUniversalLinkCallback don't get executed on iOS... It happens opening the app from scratch or waking it up from the background. I am using Nativescript 6 and iOS 9+
ngOnInit(): void { registerUniversalLinkCallback( ul => { console.log(ul) alert(ul) })
@deni-begaj did you manage to get this working? Is there any angular application example someone could refrence? Thanks
Any progress on this?
Could someone that has this issue send me a project that I can try to replicate the issue on? I tried to do it myself but I couldn't recreate the issue. It worked on iOS and Android even when the app was not previously open.
Hi,
Did you try to declaring the registerUniversalLinkCallback at your app.ts ? then use it directly from there or use the getUniversalLink from other file if you have to wait for user authentication.
@keerl I believe what's occurring here is in addition to applicationContinueUserActivityRestorationHandler on the iOS side, this should also be wired up to handle it for first launch as well:
addDelegateHandler(delegate, 'applicationOpenURLOptions', (app, url, options) => {
let handled = false;
if (url) {
setUniversalLink(url.absoluteString);
const callback = getRegisteredCallback();
if (callback) {
handled = true;
callback(getUniversalLink());
}
}
return handled;
})
Combined with the other delegate wiring, this would handle all scenarios better (first launch and resume).
Thanks @NathanWalker ! I added your suggestion and published a new version 2.0.7. I have yet to encounter this issue though, it was always working for me on first launch and resume. Hopefully this fixes the issue everyone else seems to be having.
Could anyone that encountered this issue test the new version out and confirm it has been resolved?
Further context can be seen in this discussion (bit older but still relevant): https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/issues/277#issuecomment-171568208
Further comments in that thread the extra consideration if the app is using other delegates methods through other plugins - for example firebase modifies the app delegate as well, which is why having both delegate methods helps.
Found a solution for Android and Angular.
In main.ts
registerUniversalLinkCallback(_ => {});
in app.component.ts
ngOnInit(): void { console.log(getUniversalLink()); }
it works when the application is launched fresh.
And for resume mode:
Application.on(Application.resumeEvent, function (args) { if (Application.android) { console.log(getUniversalLink()); } else if (Application.ios) { } });
@Bezlepkin thanks for this, where did you put the code for resume mode, also in ngOnInit ?
Hi,
I spending a little bit of time on this, the solution of @NathanWalker is really nice but still had some issue to populate the getUniversal Link when the delegate is manually set!
The work around is to user setUnivsealLink manually on the delegate
if (global.isIOS) {
@NativeClass()
@ObjCClass(UIApplicationDelegate)
class UIApplicationDelegateImpl extends UIResponder implements UIApplicationDelegate {
applicationContinueUserActivityRestorationHandler(application: UIApplication, userActivity: NSUserActivity, restorationHandler: (p1: NSArray<UIUserActivityRestoring>) => void): boolean {
setUniversalLink(userActivity.webpageURL.absoluteString)
console.error("getUniversalLink", getUniversalLink())
return true;
}
applicationOpenURLOptions(app: UIApplication, url: NSURL, options: NSDictionary<string, any>): boolean {
console.error(">>>applicationOpenURLOptions")
console.error(url.absoluteString)
console.error("<<<applicationOpenURLOptions")
setUniversalLink(url.absoluteString)
return true; this is for Stripe
}
}
Application.ios.delegate = UIApplicationDelegateImpl;
}
Also it may help! I use the displayedEvent to handle the link when the app in the background of foreground state and I implement the registerUniversalLinkCallback on the landing page to handle the navigation when the app was closed and open again.
// app.ts
Application.on(Application.displayedEvent, (args) => {
console.error("APP DESPLAYED EVENT");
registerUniversalLinkCallback(link => {
console.error("Link", link);
// Handle the navigation
});
})