Branch.io Ionic integration / Global Function definition needed - ionic-framework

I am trying to integrate Branch.io to my app and I get this error message:
"Uncaught ReferenceError: DeepLinkHandler is not defined"
I followed their instructions here and added their SDK:
https://dev.branch.io/getting-started/sdk-integration-guide/guide/cordova/#start-a-branch-session
In specific I'm supposed to do this:
"Then add the method DeepLinkHandler which will act as our callback when the session beings. The deep link data will be included here:"
function DeepLinkHandler(data) {
alert('Data from initSession: ' + data.data);
}
Which is EXACTLY what I did.
I talked with their support, and got to the conclusion that we need to define that function as global, so it will be possible to call it from everywhere.
Did anyone that is using Ionic with Branch.io plugin can help me fix it?
How can I define a global function in Ionic?
Thanks!

It is easy to define a global method:
in your app.js at the top of the page, simply add the method:
function DeepLinkHandler(data) {
console.log("inside DeepLinkHandler");
if (data) {
alert('Data from deep link: ' + JSON.stringify(data));
} else {
alert('No data found');
}
}
Thanks for your help, it actually solved my problem and i got the console.log :)
Edit: It indeed calls it, but now i need to figure out a different problem - how do i call my Services from the global function. Im not sure what the answer is yet.
Edit2:
The idea of solving this is firing an event. Here is the inspiration, a bit of changes and it worked.
https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues/128

Related

I'm using the https://pub.dev/packages/flutter_callkit_incoming. Nothing happens when I use the start call function. Is it something I'm doing wrong?

I have never used flutter_callkit_incoming dependency before and I seem to have problems.
Can I get help from anyone
This is the code that calls
I want to link it with fcm.
Try adding a seState({}); inside your function.

Calling a Unity WebGl Function from JavaScript (Vue)

I have a VueJs Project right now, where I'm building a web page. In order to show 3D Content and let the User work with it, I wanted to embed a Unity Project as WebGL. I´m not a professional programmer, my knowledge is more selfe-taught from what I can find at the Internet.
First of all I created a plugin, as it is explained here. My .jslib file looks like that:
var UnityJavascipt = {
$JustAWebGLObject:
{
},
SendToJavscript: function ()
{
console.log("worked!")
}
}; autoAddDeps(UnityJavascipt , '$JustAWebGLObject'); mergeInto(LibraryManager.library, UnityJavascipt );
I embed my Unity WebGl like that in Vue:
<template>
<unity src="static/Build/game.json" width="1000" height="600" unityLoader="static/Build/UnityLoader.js" ref="myInstance"></unity>
</template>
I can also call "SendToJavaScript" from my C# Script. But now it starts to get unclear for me, since I want to be able to call my "SendToJavaScript" Function (or any other one that will be added later) from a outside JavaScript. In the manual they refer to the emscripten pagefor more detailed information. But for me that all is just very confusing. I already tried to call my function like that in VueJs:
_SendToJavaScript()
But I always get a ReferenceError: _SendToJavaScript is not defined I also read in the forum here, that it would be possible to call the function like that:
UnityInstance.Module.asmLibraryArg._SendToJavaScript()
UnityInstance is the Variable from my index.html file, where UnityLoader get's instantiated. But again I'm getting a Reference Error.
It would be very helpful if someone could explain what I'm doing wrong... Communication between WebGL and Vue are essential for my project but I´m stuck here for days. So thanks in advance!!
Use unityInstance.SendMessage() documented here.
You can pass a callback or call a .jslib defined function at the end of your C# method.

onSubmit event is not fired in React.js form

My React based app contains a form and somewhere along the way it stopped working, the onSubmit even was no longer fired and the form was just simply submitted with a new http request. While trying to isolate the problem I stripped my whole app to the following snippet (which is actually this jsfiddle taken from another question):
import React from 'react'
var OnSubmitTest = React.createClass({
render: function () {
var doSomething = function () {
alert('it works!');
}
return <form onSubmit={doSomething}>
<button>Click me</button>
</form>;
}
});
React.render(<OnSubmitTest/>, document.body);
The script on jsfiddle works as it should: the message is alerted just before the form is actually submitted. I get no alert in my app, though.
If I add e.preventDefault() the jsfiddle form is not submitted at all, my form is.
The difference is that I build my app using webpack and babel from es6 but it's hard to believe that this could have any impact on this matter.
Any idea what might be the reason? What should I try next to debug that?
Update: JSFiddle showing the problem. The linked file is the webpack output (not uglified in any way to keep it readable, that's why it's so huge). You can find my code (compiled) starting on the line 53.
Mystery solved: I forgot to mark the node_modules directory as excluded (I use IntelliJ IDEA) so when I used refactoring to change some variable name form to something else, the IDE eagerly refactored the whole React and replaced all occurrences of form with the new value.
I fixed it by reinstalling all npm dependencies.

Reference Error: Can't find variable: ChildBrowser, Cordova 1.7.0, jQueryMobile 1.0.1, iOS 5.1

I'm working on my first PhoneGap/Cordova app and using jQueryMobile as well. I'm trying to get the ChildBrowser plugin working but getting the error in the title when trying to call
ChildBrowser.install()
Its in my onDeviceReady function which is being called correctly and I've even verified that the ChildBrowser.js file is being called by adding an alert and wrapping the anonymous function that file in a try/catch and it does not seem to be throwing any errors during its execution. However the var does not seem to be valid within my index.html file.
Presumably there is some 'gotcha' here I am not aware of. Any thoughts?
Thanks in advance.
Combining info from http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/ and his linked post https://github.com/phonegap-starter/ChildBrowserPlugin it appears that the
ChildBrowswer.install();
step is no longer necessary. I am now using jQueryMobile 1.1 as well. Example function used to launch google in the ChildBrowser included below. I followed the .plist setup from the first link.
function onLinkClick() {
window.plugins.childBrowser.onLocationChange = function(loc){ alert("In index.html new loc = " + loc); };
window.plugins.childBrowser.onClose = function(){alert("In index.html child browser closed");};
window.plugins.childBrowser.onOpenExternal = function(){alert("In index.html onOpenExternal");};
window.plugins.childBrowser.showWebPage('http://www.google.com',
{ showLocationBar: true });
console.log(window.plugins.childBrowser);
}
and the link itself for completeness
<p>Click here to open a child browser window to Google</p>
Hopes this helps someone else as this question went unanswered for a couple of days.

Google Analytics Easy Dashboard Library

I was trying to mess around with this new "easy" way to use google analytics API. Did not work for me even though I followed the instructions correctly. Anyone have any issues with this?
Try it out...
http://analytics-api-samples.googlecode.com/svn/trunk/src/reporting/javascript/ez-ga-dash/docs/user-documentation.html
Another easy fix is to set up a button to actually call the render method, rather than having it execute instantly like the basic example. (last line, chained method)
- or a 3-5 second timeout
Or use the "cool demo" link for a better starting point code
yes i tried it also and not worked.
It seems like i'm missing some library on my localhost. I've checked the scripts execution and when it does
if (gapi.client.analytics) {
it throws the error:
Uncaught TypeError: Cannot read property 'analytics' of undefined
this.renderFunction();
Regards
While I was getting an undefined error, I changed code in line 220 as a temporary fix.
Know it loads perfectly. this is the code:
// If the client library has loaded.
if(typeof gapi.client != 'undefined'){ //new code
//if (gapi.client.analytics) {