I am trying to implement FB's AppEventLogger in an APP in order to track user behavior and purchases.
The "APP" is hybrid - it is cordova based. It is loaded from InAppBrowser and is actually a javascript/PHP website.
I am using the Javascript API for the AppEventLogger like so:
var $fCity = $('#fromCity').val();
var $tCity = $('#toCity').val();
var params = { };
params[FB.AppEvents.ParameterNames.CONTENT_TYPE] = $fCity + ' - ' + $tCity;
FB.AppEvents.logEvent(
FB.AppEvents.EventNames.SEARCHED,
null,
params
);
Which sends the following request to facebook:
When this request is sent from the app to facebook, nothing happens. The event is not logged.
However, when the same link/request is opened/made from a regular browser, even by just visiting the InAppBrowser source page trough the browser, the event is logged.
Also, I have the Facebook SDK installed as a Cordova plugin and send events via the plugin (as an app - when it starts and ends) - then it also works. But since the app is inside the inappbrowser, I can not use that plugin for the other pages.
I have checked the whitelist plugin and connections are allowed to facebook.com. You can even see that we get a 200 response and the gif headers from Facebook's server.
Why does Facebook's AppEventBrowser not log events sent from the InAppBrowser plugin?
I could not find a way to get around the limitation. In the end I used the Cordova plugin for facebook's SDK to do what I want to.
Few things to check
1. First load the debug version of JS SDK
(js.src = "//connect.facebook.net/en_US/sdk/debug.js";)
and see the logs.
2. inAppBrowser can't access Cordova APIs so just in case any part of your code/library is trying to access a Cordova API so that may generate an issue, and maybe a request argument is missing which Facebook event requires by default to log (e.g. it logs android version etc.). You can compare the arguments with a successful request.
For hybrid apps the recommended way by Facebook is to use the event API
https://developers.facebook.com/docs/marketing-api/app-event-api/v2.8
For other platforms that utilize web-view within a native app, one option would be to utilize the App Events API to pass events from your server to the Facebook servers.
https://developers.facebook.com/docs/app-events/faq
Related
I have written an audio/video call hybrid app written with cordova/phonegap. I used
1) webrtc for actual streaming of audio or video
2) server sent events (SSE) to listen for incoming calls. https://apifriends.com/api-streaming/server-sent-events/
3) simple-peer https://github.com/feross/simple-peer
When the app is open, everything goes great, i can receive incoming call signals etc and connect. The problem is that when the app is off. I cannot open app or get any kind of indication of call status.
I decided to do some digging quickly found out that this was not possible from within a webview. I tried some plugins like https://github.com/katzer/cordova-plugin-background-mode which worked great for some time but would quickly drain the battery and your app may be rejected on appstore notices.
When my app is opened, incoming calls will be correctly captured. all i need is to open the app. I read about background push messages (silent) but failed to get these to open app. The push messages handlers were only called when app is in foreground.
So i finally fell on this doc and its the closest i got with this answer. There is no direct support for background service in Phonegap/Cordova apps.
The reason is that your hybrid app is written in JS, and your JS code
runs in an Activity that has a webview. As soon as you exit your app,
the app is suspended.
If you really want to have background service in android, you can
write your Android service in Java (native) and call your service from
your JS code. (Native for background service & JS for your app)
https://forum.ionicframework.com/t/how-to-run-cordova-plugin-in-android-background-service/6677/3
From the above, i gather i would have to do the actual logic of detecting incoming calls from the java service and if i detect anything i can force my application to open. Below is simple logic i do once app is open.
if (documentLoaded && isLoggedIn)
{
//url returns json only if there is an incoming call otherwise empty
var source = new EventSource("https://www.url.com/api/sse/incomingcall.php?userid=" + userid, {
withCredentials: true
});
source.addEventListener("incomingcalls", function (event) {
var callSession = JSON.parse(event.data);
// HandleIncomingCall();
}, false);
}
My issue is that i am not a java coder and havent written a plugin before. how would i create an android service that will listen to above url periodically and if detect any json open my app.
Google oAuth is not supported in android webView. Google recommends to use chrome custom tab for proceeding oAuth. I have also requirements of js call from my web app to native. How to configure to call native methods from web app using chrome custom tab in android similarly like js interface in webView?
Update 1
This mod Chang marked the post as duplicate but the post is different. I don't want to run any JS in my web app from native. I want to invoke method from web app to my native code via JS interface. Is there any way for CCT?
Based on Can I Inject Javascript Code into Chrome Custom Tabs the answer appears to be no.
Chrome Custom Tab is based on Chrome itself and has the same security model. The web content is only allowed access to the Web APIs (camera, device orientation, etc.) and has no access to the native app. At best the native app can capture a URI.
Even the Chrome Custom Tab documentation state that the way for a native app to handle content:
Some URLs can be handled by native applications. If the user has the Twitter app installed and clicks on a link to a tweet. She expects that the Twitter application will handle it.
Before opening an url from your application, check if a native alternative is available and use it.
Implies that either a native app handles a URL or not. My interpretation of Chrome Custom Tab is a skinnable Chrome component adjacent to the native app rather than internal to a native app like a WebView where a Javascript bridge exists.
Your desire for a Javascript bridge from a web app would mean that there would be a arbitrary way for any website code to interact outside of the web container. The rational as to why that is not allowed is given as the responses in the first link.
I am using Sinch for app to app calls.
Integrated and created iOS and Android apps which are working perfectly fine.
Now I am creating a web app to communicate with mobile apps.
I am able to make call from mobile app to web app i.e. to Javascript
I also successfully achieved web to web call, but I am unable to establish call from web to mobile app.
Following are my findings after debug:
Call In Progress is fired
Call Ended is fired after couple of seconds
Call State is 3 i.e. Progressing
Call End Cause is 1 i.e. Denied
I am following this sample and using sdk version 1.4.8
This is my calling code:
call = callClient.callUser("myUsername");
call.addEventListener(callListener);
Here you using the method "calluser()" so that method will work on web-to-web calling if want to make a call from web-to-app simply use "callPhoneNumber" method and pass number like this.
var call = callClient.callPhoneNumber('+46000000000');
call.addEventListener(callListeners);
I get it working.
Put supportManagedPush:true while initializing your JS sinch client on your web.
If app to app call working then web to app will work fine.
Note: This will enable web to call a android or IOS app while they are not running.(Using FCM wakeup)
I have to prepare an analysis about redirecting from a web site to the WhatsApp appication in the purpose to send a message. I read the documentation at https://www.whatsapp.com/faq/android/28000012 and I noticed the use of whatsapp://send?text inside the href attribute of a link.
I want to know the behavior of this feature when WhatsApp is not installed in the user device and I found nothing about in the documentation.
Thats what you called deep linking. Using hyperlinks to redirect to your app when installed and to play store (if deployed to play store) when not installed. One example that uses deep linking is facebook, but facebook uses http uri which you can choose to open to the app or to the browser as the http uri scheme is known to be a browser's uri. If you are using custom uri, then the deep link must be triggered by a browser. Refer Here for example using deeplink in chrome browser https://developer.chrome.com/multidevice/android/intents
I've been going through the steps to add a Google+ Sign-in to my web application as found in https://developers.google.com/+/web/signin/
When used in a 'typical' web site, the 'client side' flow works just fine. Now, I'm trying to integrate this Google+ sign inside PhoneGap. Since PhoneGap runs the web page as a file:// URL, the origin that gets sent in the request is file://. In every other PhoneGap I've written, this hasn't been a problem.
However, when I click the Google+ sign in button from my page in PhoneGap, the origin being sent as file:// causes the following error message:
Error: invalid_request
Invalid parameter value for origin: Missing authority: file://
I went to the Google API console and tried to assign file:// as an authorized Javascript origin. But, of course, it doesn't allow file:// to be entered as an origin.
So I'm wondering if anyone has any insight in how to do this kind of web-style (Javascript) Google+ sign in from within PhoneGap (or from a local web page where there is no server - just a page being run as a file://). I really don't want to have to do the sign-in in native code and then integrate the token back over into the 'PhoneGap' realm since that kind of defeats the purpose of writing the app once for multiple platforms.
My understanding is that you cannot use the standard client-side flow with Cordova/PhoneGap because file:// is not a valid origin.
However, you can use the In-App Browser plugin along with window.open, which will allow to initiate a "standard" client-side flow from within the application. You then listen to events on the opened window to deal with the responses.
The plugin works cross-platform so you won't have to maintain multiple native implementations.
The ng-cordova-oauth library implements this for AngularJS.
For more details about the implementation, see this tutorial for details, as well as the Google OAuth documentation.
For file://, the thing works differently.. try this as your origin: http://localhost:4567
or try this tutorial: here