What is the best way to validate monthly subscription in react native? - react-native

My react app uses react-native-iap module for in app purchases and It has a monthly subscription. I am facing few problems with validating my monthly subscription and I couldn't find any solution for that.
When user do a subscription first it will validate and update the state of my app as subscribed.
If user close the app and open it again also the validation will happen and update the state of the app as subscribed.
But user does not close the app, then there is no method to validate the subscription. User can use premium features until he/she close the app.
I tried with setInterval and periodically send request to the server to validate , but this method will reduce the performance of my android app drastically. So I can not use that method also.
Is there a correct/best way to validate monthly subscription periodically ? or Did I miss something by implementing monthly subscription ?
Thank you.

Related

React Native notification/alert

In react native app
I want to implement a feature in which any employee whenever completes a certain task then reporting person should get notified
eg. Site visit, the employee checked in the app, etc.
So please guide me
How to implement this feature and which package should I use?
What I found till now
FCM
react-native-notifications
react-native-in-app-notification
As you are using a real-time database, write a listener which dispatches an event with some payload data every time an employee accomplishes a task.
In this context, any local notification package can push local a notification for each event dispatched.
I recommend https://notifee.app/ for Local notification, It has easy API and more notification-related features.
In case you favor cloud over local notification. You should review https://docs.wonderpush.com/docs/mobile-push-notifications-react-native. They have an easier-to-use API for pushing and receiving notifications.

How to display all delivered notifications in react native? Firebase

I want to build a notification screen where it lists all the notifications associated with the current user.
I have successfully implemented Firebase to my react native app and Django rest framework backend and can send and receive notifications
But I’m having hard time figuring out how to display all the users notifications. Is that something I take care of in the backend or frontend?
You have to store all your notifications on the backend in your database, and then you just show them on the front.

Are there any info or links that clearly covers paypal integration in react native?

I would like to setup a paypal payment method exactly the same as Airbnb. The payment will be recurring on a monthly basis.
If one user is directly paying another user for a fixed amount that recurs automatically every month between just their accounts (very different from AirBnB's setup), that can be done with a Subscribe button. The easiest integration will be to create a classic HTML-only Subscribe button via https://www.paypal.com/buttons , uncheck the option in Step 2 to save the button at PayPal, and once the code is generated click the link to remove code protection. This will give you a button with variables you can adjust, per HTML Variable for Payments Standard, including the business destination in particular.
Newer PayPal Subscriptions can be used instead, but are more complex to set up, as each user will need to have the appropriate recurring Plan created for them via an API call, and you will need their Client ID and Secret to do that from your server.
Since you are using React Native, it is important to note that all PayPal flows require a web interface that includes an address bar, such as Safari View Controller or Chrome Custom Tab. A WKWebView or similar cannot be used.

React Native application with subscription: custom Stripe flow?

I've developed my custom onboarding with a one-time payment using Stripe which, if succeded, updates subscription data in my database. Then I have logic in my React Native app that will determine whether the user's subscription is expired.
Sadly, as I understand App Store requires Apple's In App Subscriptions to achieve such task. Does Google Play have the same requirement? Will my app be rejected?
https://github.com/dooboolab/react-native-iap is the only crossplatform solution I've found but does anybody know how to set up a year subscription on both platforms?
yes, in google play, you can make a free app or a paid one. Within this app, you can insert In-app products which could be subscriptions as well. It a pickle. I give my app for free for 3 months and then charge for subscription. there is a grace period you can define as well

Strategy for notification checking

Is there a recommended strategy for checking of notifications within my AngularJS app?
By 'notification' I'm talking about message alerts that are to be displayed to a user when they're logged into the application.
My plan is to notify the user of unread notifications in the app's NavBar as shown below:
My app communicates with my restFul API (written using Node.js, express, MongoDB), so I anticipate that new notification will be written to a MongoDB collection with details the user the notification is intended for.
What I'm unsure about is how the AngularJS application will check for notifications once a user is logged on. I could call my API for unread notifications every time the user navigates from one path to another but that seems simplistic and it wouldn't work if a new notification occurs whilst a user is viewing a page.
Another way would be some sort of timer system that checked, say, every 30 seconds. But this would results in unnecessary polling of my API when there aren't any new notification for a user.
So, wondering if there is a recommended strategy. Thanks for your help.
Polling is a solution but it is very inefficient. The solution to your problem are websockets. Websockets is a technology that provides a full-duplex bidirectional communication between your clients and your server. So you can send messages from your server to your connected clients. Your server maintains an array of connected clients and you just have to know which ID you need to send a message to it.
For your stack, the best solution I have came to is Socket.io http://socket.io
It also have cool features. For example, you can "observe" models, so if a model change in your database, for example an update to a user profile is made, you can trigger an event and automagically send a message to your client. This client get and handles the notification and do something, like put a badge on your alerts icon.
Hope this is useful for you.