ReactNative Facebook Login Issue - javascript

I followed the steps here (https://developers.facebook.com/docs/react-native/configure-ios) for facebook login with iOS. I'm using a custom login call from my own component. The login confirm dialog comes up fine but when I hit "Continue" mobile safari seems to get stuck:
I'm seeing a bunch of weird warnings:
: -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
requesting pasteboard fb_app_attribution
Apr 12 08:08:42 MacBook-Pro pasted[69862] : ...requesting pasteboard fb_app_attribution completed. Error: (null)
Apr 12 08:08:56 SafariViewService[70243] : Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
But none really yield any good search results. Any help would be amazing. Thanks.
P.S. My code for calling login:
handleFacebookPress() {
LoginManager.logInWithReadPermissions(['email']).then(
(result) => {
if (result.isCancelled) {
console.log('Login was cancelled');
} else {
console.log('Login was successful with permissions: '
+ result.grantedPermissions.toString());
}
},
(error) => {
console.log('Login failed with error: ' + error);
}
);
}

I had the same issue. I was able to fix it by adjusting the Oauth url in the facebook application portal to be https://localhost:8081 as my react native localhost was using port 8081

Related

http-proxy-middleware econnreset error after successful post request

Developing a contact form using Nodejs/Express and create-react-app following this tutorial https://www.youtube.com/watch?v=o3eR0X91Ogs. The issue that I'm running into is that when I hit submit on the form the message succeeds, and I get it in my inbox. However, in the developer console, I am hit with the timeout error I set on the axios.post located in Contact.js, and in my terminal it logs message sent, console log located in index.js, immediately throwing the following error afterward:
HPM ERROR: Error: socket hang up
[1] at connResetException (internal/errors.js:612:14)
[1] at Socket.socketCloseListener (_http_client.js:443:25)
[1] at Socket.emit (events.js:326:22)
[1] at TCP.<anonymous> (net.js:673:12) {
[1] code: 'ECONNRESET'
[1] }
[1] [HPM] Error occurred while trying to proxy request /api/contact/ from localhost:3001 to http://localhost:3000/ (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Does anyone know why this error is occurring, and how I can fix it? The message sends but hangs afterward which prevents the app state from resetting (resetForm). At the same time, the axios.post in Contact.js doesn't update the state of sent to true.
The Github repo for the project.
Edit: I've been stuck on this for a few days now. Looked at similar questions, attempted ALL the fixes I could find, and this error still persists.
This is a common misunderstanding about how ExpressJs responses work. If you don't send a response to the request, it'll be stuck forever. So all you have to do is to send a response! Also, the res variable was re-defined in the callback of sendMail function. Here is the fix:
app.post('/api/contact', (req, res) => {
// ...
smtpTransport.sendMail(mailOptions, (err, mailResponse) => {
if(err) {
console.log(err);
} else {
console.log('Message sent!');
}
smtpTransport.close();
return res.send(err ? err : 'Message sent!');
});

Accessing Node with React-native returns an unhandled promise rejection warning (id: 0)

I have a test backend route,
router.get("/test", (req, res) => {
console.log("it works!");
return res.json({ msg: "Success from backend" });
});
And in my react-native component, I have a method:
export const registerUser = async () => {
const res = await axios.get("http://localhost:5000/api/users/test");
console.log("response received --> ", res.data);
};
I get the error:
[Unhandled promise rejection: TypeError: Network request failed]
However, when I access http://localhost:5000/api/users/test through my browser, I get the expected response and behaviour.
Not sure what I'm doing wrong here. I've even tried using the react-native-axios library instead of just axios, but I get the same error/warning. Also, I'm translating a functioning ReactJS app to React-native, so I'm positive my backend logic/syntax is configured and correct.
Edit
Full warning below:
Edit 2
Code for axios call:
try {
console.log("trying");
const res = await axios.get("http://localhost:5000/api/users/test", {
headers: {
"Access-Control-Allow-Origin": "*"
}
});
console.log("got it"); // never reached
} catch (err) {
console.log("oh no"); // this doesn't log either, oddly enough
console.log(err);
}
Warning thrown:
[Unhandled promise rejection: TypeError: Network request failed]
* client/node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:504:29 in onerror
* client/node_modules/event-target-shim/lib/event-target.js:172:43 in dispatchEvent
* client/node_modules/react-native/Libraries/Network/XMLHttpRequest.js:580:29 in setReadyState
* client/node_modules/react-native/Libraries/Network/XMLHttpRequest.js:394:25 in __didCompleteResponse
* client/node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:190:12 in emit
* client/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:366:47 in __callFunction
* client/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:106:26 in <unknown>
* client/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:314:10 in __guard
* client/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:105:17 in callFunctionReturnFlushedQueue
Using Postman or directly from browser works.. through React-native it doesn't
The local development server cannot be accessed because the port has not yet been passed on by the ADB. Therefore, in this situation, you can map a local server port or use a local IP address to perform two tasks.
Obtain the port from the ADB by executing the following command at the terminal:
adb reverse tcp:5000 tcp:5000
OR
You can also use local IP. Shake the instrument or press and hold the menu button to open the developer menu. Click Open Dev Settings, and then click Next. then tap Debug server host & port for device. Here you can enter your machine's local IP with port number 5000
Example
192.168.1.50:5000

Sending 500 ("Server Error") response when visiting any url in Sails App

I am using Sails and Mysql to handle the database of my app. I recently clicked on a chrome autofill URL that took me to a 404'd page, since that url localhost:1337/companies was not active in this project.
Ever since I did that, my app returns
error: Sending 500 ("Server Error") response:
Error (E_UNKNOWN) :: Encountered an unexpected error
: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'where clause'
and
Details: Error: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'where clause'
any time I go to a url in my app. I tried cloning my app and relinking the database to no avail. I see this is a common issue people run into with sails, but none of the mentioned solutions were able to fix it for me.
Everything was working before I clicked that URL which makes me believe it may be a route issue, but the app still works, it will just fill up my terminal with the above errors.
Any help is greatly appreciated!
Edit: this is the custom API call I was working on in my controller.js when I started seeing the error:
winner: function (req, res) {
User.findOne({id: req.param('id')}).exec(function(err, user) {
if (err) {
return res.negotiate(err);
}
else {
var u = user;
u.totalwins++;
u.save();
sails.io.sockets.emit("chat", {verb:"score", data:{id: req.param('id'), name: user.name}});
}
});
}
Also receiving this error in my chrome-browser console:
:1337/user/quizzes Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Can't send mail with Cloud Functions for Firebase

I'm trying to send an email from a Cloud Function using the sendmail package.
It works when I host my "send function" locally. And I can deploy the function without problems to my Firebase project.
In the log at Firebase I can see this message:
Error: queryMx ESERVFAIL hotmail.com
at errnoException (dns.js:28:10)
at QueryReqWrap.onresolve [as oncomplete] (dns.js:219:19)
I'm neither familiar with sending emails from servers or Cloud Functions for Firebase. My question is why I got this error and how I can make it work?
Here is an excerpt from my function:
sendmail({
from: body.name + ' ' + '<' + body.email + '>',
to: 'soerensmed#hotmail.com',
subject: 'Henvendelse via kontaktformular',
html: html,
}, function (err, reply) {
if (err) {
console.log(err && err.stack);
response.status(500).end()
}
else {
console.log(reply)
response.status(200).end()
}
});
I'm developing a website where people can contact me through a contact form. The goal is to receive an email with the message... If this approach isn't possible I'm open for suggestions on how I can set this contact-email-thing up using Angular and Firebase.
It will not work with cloud function with free spark account. You should upgrade as it is clearly defined in pricing section in network box. https://firebase.google.com/pricing/

Local Storage error with JBoss

I have a Web App on Firebase, the application is running on the server fine, the alert is also working fine it shows the correct user id,
but with the BrowserSim(JBoss Plugin) Emulator on Eclipse, I got these errors:
!JavaScript WARN: FIREBASE WARNING: Exception was thrown by user callback.
!JavaScript ERROR: TypeError: 'null' is not an object (evaluating 'localStorage.setItem') on line 17
Here is the Javascript code:
rootRef.authWithPassword(userObject, function(error, user) {
if(error) {
alert(error + " " + error.code);
location.refresh();
}
if(user) {
alert(user.uid);
localStorage.setItem("uid", user.uid);
location.href = "overview.html";
}
});
Why does the localStorage isn´t working on the emulator ?
The problem was the emulator cache from Eclipse for the internal storage was full and has a bug. It works a few times fine and after this it has a bug and returns null.

Categories

Resources