Proper way to send FCM device token to a webview - react-native

I have a webapp built on Laravel that is to be displayed on a mobile app (both android and ios, which are being built using React Native) via WebView.
I managed to use evollu/react-native-fcm to generate the token.
My question is: what is the proper way to send this token to the WebView, so my webapp can relate it to a user and store it on the database?
My first idea was to pass it along to the URL being called by the WebView as a GET parameter, but the parameter always come blank on the other side, probably because the token is requested asynchronously and when the webview is called it didn't come yet.
What can I do?

Either as a url parameter or via postMessage. In both ways you have to wait until the token is available. So load the page or render the webview when the token is available. Or you pass the token via postMessage immediately after the token was received.
The postMessage method is the recommended way, because you can load the page and wait for the token at the same time.

I managed to delay the rendering until the token was ready by using an if on the render method that would not return the webview if a state "loading" is true; then in the function that gets the token I used setState to change the value of loading to false.

Related

Can't use Moneris in React native

I want to put credit card number in a field and on clicking a button to retrieve its token. I don't find much information but the thing that I found is:
https://developer.moneris.com/Documentation/NA/E-Commerce%20Solutions/Hosted%20Solutions/Hosted%20Tokenization
I tried with it but still can't make it work. If I put this whole code in webview html part it will call the function on the first screen render. If I try to get the functions out of the webview and use them I can't take the specific iframe with document.getElementById('monerisFrame').contentWindow;
Any thoughts how can I accomplish my task?
You can use Moneris Apis to communicate in React Native :
We can create XML Post Request and connect with the Moneris server with your API Token and Store Id
Follow this blog :
https://medium.com/me/stats/post/7129b5a8b4a2

how to know if webview can scrolled? react-native

I was finding out a way to know if webview can scroll or not, but I found nothing special. I am using react-native-webview. Is their any way to find out?
react-native-webview
supports
postMessage
method, which lets you to send a message to your app from webview. If you want to track user scrolling, you can basically set up eventListener and inject that javascript inside your webview and then send scrollOffset with postMessage to your app (where you can handle that event). Or you can just pass postMessage wit payload window.innerHeight when the document in webview loads. In order to understand how postMessage callback works you can check my example app, which was actually created for another issue (see github description), but will suite this case as well.
https://github.com/GFean/webview-example-app

Unable to successfully call captureVisibleTab() despite requesting <all_urls> permissions

I'm working on a browser extension for React DOM. This extension has a "Profiler" UI which measures render performance for React components. I recently added screen captures to this Profiler so that it can show images of the DOM each time React updates it.
To do this, the extension calls chrome.tabs.captureVisibleTab in response to a request from the DevTools extension UI. (This request is made each time React commits changes to the DOM.)
I've required the <all_urls> permission for now, based on the documentation for this API, which says:
You must have the <all_urls> permission to use this method. (Alternately, Chrome allows use of this method with the activeTab permission and a qualifying user gesture).
(The Chrome documentation for this API doesn't mention either way.)
In my experience, I am able to capture the screen after updates caused by e.g. clicking on an anchor element. However, other types of updates (e.g. "scroll" events, programmatically calling click() on an element) fail with an the following error being logged to the background script:
Unchecked runtime.lastError: Cannot access contents of url "". Extension manifest must request permission to access this host.
Is the documentation wrong about this API? Have I defined my permissions incorrect? Any help would be appreciated!

pass url from view to controller on PaypalReturnView

I have almost got my mobile web app sorted, I just need to get the return url from the return page after finishing my paypal transaction, I need the url as it has the token and payerid so I can finish off the payment.
I have seen that I can get the Request.Url.AbsoluteUri, but is there anyway I can decode this so it is in a normal string format, that I can then extract the token and payerid, also is how do I get this information on the view loading, opposed to doing it on a button press..
Thanks

facebook dialog to add facebook tab app - returns - tabs_added[pageId]=1

It seems the new dialog to tab app to a page -> https://developers.facebook.com/docs/reference/dialogs/add_to_page/ - calls the app url with a GET (redirect_uri?tabs_added[nnnnn]=1) (where nnnn - pageId of page the app is being added to)
I can't find the documentation around whether when the app is removed from the page, the same url will be called with a GET (redirect_uri?tabs_added[nnnnn]=0) ?
I am keen to process the uninstall of the app from the page, if possible. (I have tried to test this, but don't get a trigger to my redirect_uri upon an installed, unlike the one that is called upon an install..)
My question is - whether there is a way to get a delete page callback into the app (when a page uninstalls/deletes the app from the page) ? From the syntax on install GET call (?tabs_added[nnn]=1, it seems that this might have been designed with an intention to call a GET with ?tabs_removed[nnnn]=1 or tabs_added[nnnn]=0 when the app is deleted from the page ?
Empirically, the answer to your question is No. Nothing on my server gets called by Facebook when the Page Tab is removed.
Go to the advanced tab on the facebook app settings, and put a URL of your choice into the 'Deauthorize Callback URL' field. You will receive a callback on that and you need to parse the signed request.
Example in php:
$helper = $fb->getPageTabHelper();
$signedRequest = $helper->getSignedRequest();
if ($signedRequest) {
$payload = $signedRequest->getPayload();
//trace(print_r($payload, true));
$pageId = $payload['profile_id'];
//You can now update your records using $pageId
}