-
-
Notifications
You must be signed in to change notification settings - Fork 50
conflict with NativeScript URL Handler Plugin #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you please share a bit more info about the app you are trying to build, the type of the flavour Angular/Typescript/Vue, the versions of the dependencies used in the app etc. |
Hi @DimitarTodorov, I confirm this issue in iOS. I will provide complete information and a demo app in the next days, as you suggest. Meanwhile, my app is core NativeScript with Typescript and these are the dependencies:
If I init the Facebook plugin in |
any news on this ? |
Hi, I just tried to reproduce this using the demo app in this repository, I just added the handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
}); The app compiled and ran on iOS 13.3 and I was able to log in to facebook. Is there something I am missing? If possible, send a small app and steps that can be used to reproduce this reliably. Thanks! |
Hi @lini, |
Here is what I tried:
import { handleOpenURL, AppURL } from 'nativescript-urlhandler';
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
});
<dict>
<key>CFBundleURLName</key>
<string>org.nativescript.demo</string>
</dict>
Is there something I am missing? |
@lini that's the problem, the facebook login is intercepted by the nativescript-handler plugin and not forwarded to the facebook plugin. When looking at the source, we can seed that both plugins overrides some of AppDelegate's methods to catch "open url" actions, that's where te conflict happens |
Hm, I tried that as well (both import * as application from 'tns-core-modules/application';
import { init, initAnalytics } from "nativescript-facebook";
import { handleOpenURL, AppURL } from 'nativescript-urlhandler';
application.on(application.launchEvent, function (args) {
init("1771472059772879");
initAnalytics();
});
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
});
application.run({ moduleName: "app-root" }); |
@lini Yes the order of initialization matters (maybe the order of import/require of that plugins), you can't get both plugins working, it's either facebook-login or urlhandler. I faced a similar conflict with this plugin and nativescript-plugin-firebase which does the same AppDelegate overriding. A solution would be for the plugins developers to align themselves on how to override the AppDelegate (or use a kind of shared service that emits the needed events). |
As a workaround, how could we catch the data from urlhandler and pass them back to this plugin ? |
Hi, I also try other plugin (name : Nativescript plugin Universal Links). We confirm this plugin cannot working with Facebook plugin. I am get the same result. Anyone Know How to using Universal link or URL Handle with Facebook Login in Nativescript IOS APP? Patrick |
Same problem here. Any solution? |
Hi everyone! Any news about issue? I have hit with this problem also. @daweedm do you have example to get around this problem? Any idea how to override the AppDelegate? |
I found that the origin of the conflict was the use of I managed to solve this with the following (ugly but working) workaround : Apply a custom callback handler by overriding the AppDelegate. For this I put the following code at the bottom of the Disclaimer : this was a quick fix to get a prototype working quickly. For a "real" project, editing dependencies source files directly is a bad habit. (function () {
function extractAppURL(urlParam) {
if (!!urlParam) {
var url_1 = urlParam.toString(),
params = new Map(), urlWithPath = url_1.indexOf('//') < url_1.length - 2,
urlWithParams = url_1.indexOf('?') !== -1, path = urlWithPath ? url_1.substring(url_1.indexOf('//') + 2,
urlWithParams ? url_1.indexOf('?') : url_1.length) : null,
parameters = url_1.substring(url_1.indexOf('?') + 1).split('&');
if (urlWithParams) {
for (var i = 0, len = parameters.length; i < len; i++) {
var paramData = parameters[i].split('=');
params.set(paramData[0], paramData[1] ? paramData[1] : null);
}
}
return {
params: params,
path: path,
toString: function () {
return url_1;
}
};
} else {
return null;
}
}
getAppDelegate().prototype.applicationOpenURLOptions = function (application, url, options) {
if (getAppDelegate().prototype.___DS_IOS_HANDLER) {
FBSDKApplicationDelegate.sharedInstance.applicationOpenURLSourceApplicationAnnotation(application, url, options.valueForKey(UIApplicationOpenURLOptionsSourceApplicationKey), options.valueForKey(UIApplicationOpenURLOptionsAnnotationKey));
var lastArgument = arguments[arguments.length - 1];
var previousResult = lastArgument !== options ? lastArgument : undefined;
if (!previousResult) {
var appURL_1 = extractAppURL(url.absoluteString);
if (appURL_1 != null) {
setTimeout(function () { return getAppDelegate().prototype.___DS_IOS_HANDLER(appURL_1); });
}
return true;
}
return previousResult;
}
};
getAppDelegate().prototype
.applicationContinueUserActivityRestorationHandler = function (application, userActivity, restorationHandler) {
if (getAppDelegate().prototype.___DS_IOS_HANDLER) {
if (userActivity.activityType === NSUserActivityTypeBrowsingWeb) {
var appURL_2 = extractAppURL(userActivity.webpageURL);
if (appURL_2 !== null) {
setTimeout(function () { return getAppDelegate().prototype.___DS_IOS_HANDLER(appURL_2); });
}
}
return true;
}
};
})(); Then, wherever you need, you can register a custom callback in your app source code, like this : require('tns-core-modules/application/application').ios.delegate.prototype.___DS_IOS_HANDLER = (url) => {
console.log('GOT url from ___DS_IOS_HANDLER', url);
setTimeout(() => this.ngZone.run(() => this.handleOpenURL(url)));
}; It may not solve your issue because mine was due to the use of The workaround is simple but the issue itself is vicious, I spent a whole day searching for the reason why this damn plugin was not working. Good luck. |
Hi,
I am using the Facebook plug-in with NativeScript URL Handler Plugin. This is not working in IOS Platform. But the Android is working.
Anyone know have this problem and know how to solve it?
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
});
I am enabled the facebok plug-in in App. Above code will be not working
Patrick
The text was updated successfully, but these errors were encountered: