How would I connect a react-native mobile app to Django - javascript

Suppose I wanted to make a simple react native app with just one button connect to a Django backend. For example, when a user presses the button, it should connect to the server and return “hello world”. I know you have to use a rest api, but how would the code look in the us and the .Py
Also, when you combine them, is it possible to use the Django user model, or are some features blocked when you use a rest-api like a #login_required.
Thank you for your time.

Related

Is it ok to use two different ReactJS Code bases for one project

As I'm starting my carrier as JavaScript developer I always have this question. Let's say I'm developing an App using ReactJS. And in that project, I want to create separate domains for Admin and Client.
Because the admin can log into the backend and check the inventory, it won't get mixed with the Client / User when using the same login. And the code is also getting smaller
As an Example.
Admin is logged using admin.site.com
User / Client is logged in using site.com/login
Now, I decided to go with NodeJs as the back-end for the project. For front-end of the back-end (UI), I thought of using REactJS. Also to use Admin LTE.
For Client-side I will be also using ReactJs.
So there will be two ReactJS code bases and one Node JS.
My Questions are,
Is this method ok?
Or can I do this on one ReactJS code base?
Do you guys have any suggestions for me?

How routing in Express.js/Node.js web app?

I'm working on this web app that include several pages.
I really would know if it's better handle the router in the backend (Node.js) or in the frontend (React.js) or with both (I didn't understand in the Internet).
For example, how have I to work with the login page (that will re-direct on the user area).
Thanks
I don't know how big your project is, or its requirements, but if this is a personal project I would suggest using the React Router Library. You can make a call to your Express app from the Front, and based on the response you get back you can route the user to wherever.
In a project of mine I had an express route for login that looked for the user in a database, then checked to see if they provided the correct password. If the user provided the wrong password or if the account wasn't found I sent back an error message. If the user provided the right password I sent a success message to the front. I would listen for the response on the frontend, if I received a success message, I would call useNavigate from React Router to route the user to the user page.
Here is the documentation for React Router Dom: https://www.npmjs.com/package/react-router-dom
If this is a bigger project and you need to think about accessibility and search engine optimization, you would have to find a way to render React from the backend. Its called server side rendering, which I'm not familiar with.
Hope this helps a little.

Open selection for mail client with React Native Linking API

With Linking API in React Native, we can do something like that:
Linking.openURL(`mailto:${receiverEmail}`);
But, with this approach, the React Native app will open default mail client app instantly (e.g: Gmail), what I want to do is instead of open default mail client app, a pop up should come from bottom of the app (like Share API in React Native does) and let user chooses from various of mail clients in their device.
Is there anyway to do it ? I really appreciate it, even, a suggestion.
Thanks in advance.

Laravel and Flutter Notifications System

I Want to Build a Web App with Mobile App in one platform. So, Both of Them will use the Same Database which is MySQL.
I want to use Laravel as backend and flutter for mobile app
Also, I want to build notifications system "when the user does something he will get pop up notification"
and that is the problem.
I searched a lot about this but I found nothing.
for Laravel, I can use Pusher and it's pretty easy.
but I didn't found anything to integrate it to flutter.
NOTE:
I'm beginner at flutter. But i'm good at laravel.
UPDATE
it's okey if there is any other method to do this
For flutter there is package called flutter_local_notifications,
link: https://pub.dev/packages/flutter_local_notifications
also there is pusher package
https://pub.dev/packages/pusher
so you can use these 2 together, so when a user trigger an event with API, a listener will send notification to pusher, so the other user would listen to it using pusher package.
At this moment you got the notification on your mobile using pusher package, only then you can trigger local notification using the other package instantly.

Server Sent Events with Hybrid Application

I'm working on a hybrid app that is based on Angular 1.5. In part of the app now, the client wants a messaging system for the admin of a group to be able to message the normal worker/user. I want to check and see if this is done, would server sent events be the solution? If so, do I continue to let it run as the user has the app open? How does this affect performance?
I am presuming authentication would need to be performed against users in order to differentiate between admin and worker accounts.
Have Angular send AJAX calls to your server, which will check the users' authentication status before the client-side view is rendered.
You should research the resolve property in Angular in order to implement this type of solution.

Categories

Resources