Meteor 1.3+ Accounts Facebook Login for iOS not working

做~自己de王妃 提交于 2019-12-23 06:50:09

问题


I have been trying to find a solution (sadly for 3 months now) to login with Facebook using Meteors Accounts Facebook on iOS. I have tried just about everything a Google search will come up with, reached out on the Meteor forums and even opened up a Github issue.

But this problem still escapes me. Everything works fine on desktop but as soon I as I test on mobile I get a Facebook error "Not Logged in. You are not logged in. Please login and try again" .

I have found several others with this issue and very little input on a full proof answer. And at this point I am starting to get desperate.

This wasn't a problem until Meteor went to 1.3 up.


回答1:


It's working for me with the following setup

  1. Latest version of Meteor and Xcode
  2. Account related Meteor Packages

    accounts-base
    accounts-password
    accounts-facebook
    accounts-google
    useraccounts:materialize 
    service-configuration
    accounts-ui
    splendido:accounts-meld
    
  3. Rendering the template with

    {{> atForm}}
    
  4. I also have 2 cordova plugins added (for that create a file inside .meteor folder with the name cordova-plugins and the following content

    cordova-plugin-meteor-webapp@https://github.com/meteor/cordova-plugin-meteor-webapp.git#8bf95eed3f313299fc2de33658866278eea2cdc5
    cordova-plugin-inappbrowser@https://github.com/apache/cordova-plugin-inappbrowser.git#2df0e72c36f1fda35c04b3b06bd7beaafaae6ee9
    
  5. Also make sure you have the following line in your html's head tag

    <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval' data: " />
    
  6. Finally add the following lines in your mobile-config.js file

    App.accessRule('http://*', {type: 'navigation'});
    App.accessRule('https://*', {type: 'navigation'});
    

Also run a meteor reset command before building




回答2:


Here might be the problem in the GitHub issues

According to the author- It appears that WKWebView in iOS 10 no longer applies the Meteor Cordova CSP (default-src *) to websockets, and blocks the connection, with the below message. This breaks production apps that make websocket connections (perhaps only connections other than the default connection to the Meteor server? not sure) when their users update to iOS 10 (which has been released).

The issue lies in the codeline

<meta http-equiv="Content-Security-Policy" content="default-src * data: blob: 'unsafe-inline' 'unsafe-eval';">

You can try to replace it by

<meta http-equiv="Content-Security-Policy" content="default-src * 'self' data: blob: 'unsafe-inline' 'unsafe-eval' wss://*.ourdomain.tld ">

in the file https://github.com/meteor/meteor/blob/master/packages/boilerplate-generator/boilerplate_web.cordova.html

and then update the Meteor 1.4 by running meteor update boilerplate-generator

You can also try updating meteor update --release 1.4.2-beta.4 as mentioned in the link that

This package is run during the build process and updating this package on a project level would not change what files are used to build the app.

Also if it still doesnt work then as suggested by this author

You can add a simple plugin meteor add cordova:meteor-ios10-csp-fix@0.1.0

Repo is here and the npm page is here

Hope this helps.

Full attribution goes to the github link and the authors mentioned above




回答3:


To make this work for me, I upgraded to the latest version of meteor, accounts-facebook, etc.

Next I deployed a web version of the app with working facebook login. Then I tested the web app facebook login. All good once the valid oauth redirect URI are added in your facebook app settings. These should be something like https://example.com

Then I ran in terminal meteor run ios-device --settings settings.json --mobile-server https://example.com

My mobile-config.js file also contained as recommended by @Afzal Hossain App.accessRule('http://*', {type: 'navigation'}); App.accessRule('https://*', {type: 'navigation'});

The app put on my device worked for logging in.

No need for cordova plugins or CSP policy any more as meteor updates have made these unnecessary.




回答4:


I have fixed the same issue by specifying correct Url in Facebook App's "Valid OAuth redirect URIs".

Earlier, I had specified http://<domainname>/_oauth/facebook?close

which did not work. After some debugging, I found that the URL should be

http://<domainname>:<port>/_oauth/facebook?close (with port number)

So In case of a server running on http://localhost:3000, it would be http://<device ip/external ip>:3000/_oauth/facebook?close

And, in case you are running app with --server=http://www.domainname.com then it would be http://www.domainname:80/_oauth/facebook?close (port 80 for HTTP )

Now, I see the Facebook App login page and can login.

But now I am stuck with closing the InAppBrowser after authentication. Any help in this regard would be great!



来源:https://stackoverflow.com/questions/39936777/meteor-1-3-accounts-facebook-login-for-ios-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!