Childbrowser with Cordova 1.7 iPhone issue - iphone

Can any expert here please point me to some valid walkthrough on how to make the ChildBrowser work with Cordova 1.7 in iPhone? I have found lots of documents and blogs out there that tell you how to do it, but none of them have worked for me. It is not a whitelist issue for sure, as for the time being I have set it to the wildcard *, so whitelisting problems can be safely ruled out I guess. In some cases, ChildBrowser was successfully installed, but when I called the showwebpage function, it just would not show up (there wouldn't be any errors either!). Other times, it just won't even install. I have already spent 2 days on it, and am still clueless. Just hoping if you could help me out. Any help would be appreciated.
I could finally get the ChildBrowser to open up following what Dhawal has suggested below. But the onLocationChange event never seems to fire. Again, this seems to be a common problem with Cordova 1.7. Any workarounds apart from rolling back to some older Cordova version? Any help would be appreciated.
Here's what I am trying to do:
window.plugins.childBrowser.showWebPage(url, { showLocationBar: true });
window.plugins.childBrowser.onLocationChange = function(loc){ alert("In index.html new loc = " + loc); };
Ok, got it to work. Seems like ChildBrowser is still compatible with older versions of Cordova only. Had to delve into Objective-C and make changes in the plugin to make it work.

I have a basic application which has childbrowser integration with Cordova 1.7. I have put the steps also to generate build same application.
ios-cordova-childbrowser
Edit
Childbrowser events were not getting called properly so I added this fix in ChildBrowser.js file to resolve it.
if (cordovaRef && cordovaRef.addConstructor) {
cordovaRef.addConstructor(ChildBrowser.install);
// Make ChildBrowser global
window.ChildBrowser = ChildBrowser;
} else {
console.log("ChildBrowser Cordova Plugin could not be installed.");
return null;
}

Related

My Ionic app throws a "has no method 'startInit'" error when using OneSignal

In my Ionic smart phone app, I'm using OneSignal to handle push notifications. According to some OneSignal docs, I need to initialize their plugin like this:
window.plugins.OneSignal.init(
"b2f7f966-d8cc-11e4-bed1-df8f05be55ba",
{googleProjectNumber: "703322744261"},
notificationOpenedCallback
);
This works for me. But other documentation says I should do this:
window.plugins.OneSignal
.startInit("YOUR_APPID", "YOUR_GOOGLE_PROJECT_NUMBER_IF_ANDROID")
.handleNotificationReceived(function(jsonData) {
alert("Notification received:\n" + JSON.stringify(jsonData));
console.log('Did I receive a notification: ' + JSON.stringify(jsonData));
})
.endInit();
This is what I would prefer to do, since I really want that "handleNotificationReceived" option, not just the "notificationOpenedCallback" option. But it's not working for me. I get a Javascript error saying the method "startInit" doesn't exist in the "window.plugins.OneSignal" object. It's right. There is no method "startInit", so how can I use the code that calls it?
So what am I doing wrong? Am I not using the latest version of OneSignal? I just ran "ionic plugin add onesignal-cordova-plugin --save", so I should be using their latest version. (It installs version ~1.13.2, according to my config.xml).
How can I fix this?
The newer 2.+ version of the SDK is not out yet. You should refer to the old docs for this here
EDIT
The new version of the SDK is now out and you can get it here. Also new docs are here.
Was getting the same issue. You could try reinstalling the plugins or add the platform again android/ios. That worked for me.

Ionic: Disqus embed loads locally, but not in production (or on an emulator)

I've built a simple Android app, as a companion piece to a publication website, with the Ionic framework, and (after much head-banging), I managed to get the Disqus threads on the app to sync with those on the site. After trying a few different methods, I ended up going with this directive from Michael Bromley to implement the Disqus widget in the app, which is hiding behind a "Comments" button at the bottom of each article on the app's UI.
Running with Ionic Serve, everything works brilliantly. Outside of the local server: not so much. I don't get an error message from Disqus – it simply doesn't load the iframe at all. I'm refraining from posting code, because I'm wondering if this is simply a CORS issue, or maybe something simple that I'm overlooking.
One thing that might be of importance: I don't have the Crosswalk plugin installed on the app – I'm not sure if my thinking is correct, here, but could it be possible that Disqus is compatible with Chrome, which is why it runs fine when I'm testing it on my browser, but isn't compatible with Android's default browser? I'm not extremely well-read on Crosswalk, but I believe it tells the app to use a specific browser – if so, could installing it fix the problem? I'd go ahead and install it, and see if it helps, but I'd like to avoid tampering too much with an otherwise-working app if the issue is something completely unrelated to the plugins.
One weird caveat: The Disqus comments loaded on one article just fine when I tested the app on Genymotion. I deleted that article, and created a new Test article on my site (thus firing up a new Disqus thread), and that failed to render on Genymotion. It seems very... random, I guess, that it would work once. It would seem that it would either work all the time, or never work.
EDIT: While running on Genymotion, no errors appear in the console when debugging the app with WebView. The fact that I'm not getting a "Refused to load" error makes me think that Disqus is getting called and, for whatever reason, is refusing to answer the phone at all.
I can spend hours trying to figure something out, and then... well, as soon as I post a question, I end up figuring out the answer five minutes later.
I dug looked into the code for the directive I was using (which I highly recommend for anybody looking to easily implement Disqus into any AngularJS project), and I noticed that was calling for embed.js with the following string:
....
if (!$window.DISQUS) {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + scope.config.disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
} else {
....
Amending dsq.src = '//' + scope.config.disqus_shortname + '.disqus.com/embed.js';to add a protocol, making it dsq.src = 'http://' + scope.config.disqus_shortname + '.disqus.com/embed.js';fixed the issue on Genymotion. I'll ship the updated APK to the Play Store, and comment on this answer to confirm whether or not it holds up there, as well.

Safari 8.0.3 fails to load NPAPI plugin (Mac OS X)

I am very new to Plugin development. I have an existing NPAPI plugin that works fine on Firefox. I want to reuse it and load it in Safari as well. To get started I downloaded the sample plugin from http://mxr.mozilla.org/mozilla2.0/source/modules/plugin/sdk/samples/basic/mac/. Built it in XCode and added the plugin under /Library/Internet Plugins/. I see that browser notifies asking for permission to access the plugin but I don't see it actually getting loaded. I am doing the following.
var npPlugin = document.createElement("embed");
(npPlugin).type = "application/x-myPlugin";
(npPlugin).data = "data:application/x-myPlugin,";
npPlugin.setAttribute("style", "width:0;height:0");
window.document.body.appendChild(npPlugin);
Couldn't find a good way to debug it, so tried the raw way of creating a file and writing logs to it. I added this to both NP_GetEntryPoints & NP_Initialize with a hope that one of these functions will be invoked at the time of loading and will log for me. I didn't see any signs of my plugin getting loaded. Any ideas on how to make it to load or how to actually debug it?
I commented out any code that was other than the NPAPI required methods. It helped me get around this problem.

Facebook SDK for .NET - Security Warning Issue

everyone. Today I encounter the following message in my Windows Phone App:
Success
SECURITY WARNING: Please treat the URL above as you would your password and do not share it with anyone.
This happens when my users Login through the Web Browser Control, which get the Login URL from the GetLoginUrl method from the Facebook SDK for .net. This problem is not only happening in my Apps, I've seen users from other Apps having the same problem.
Anyone found a solution to this?
I'm running this SDK in my PictureWeather (Windows Phone 7 & Windows Phone 8) and Picture2Cams (Windows Phone 8) Apps.
Had the same problem. In my app I changed this line:
parameters["redirect_uri"] = "https://www.facebook.com/connect/login_success.html";
To this line:
parameters["redirect_uri"] = "https://m.facebook.com/connect/login_success.html";
And it works now.
Had the same problem on our WP8 app using the Facebook SDK for Windows Phone (http://facebooksdk.net/docs/phone/) and the indicated solution with changing the redirect URL also worked for us.
Thanks for submitting this solution.
I ran into this problem, myself, and did a bit of digging to get to the root of the issue. The problem seems to spring from some unknown (to me, anyway) change on Facebook's side, where previously the authentication response URL was in the form
https://www.facebook.com/connect/login_success.html#access_token= ...
for some reason it now comes back from the login flow as
https://www.facebook.com/connect/login_success.html#?access_token= ...
The code in FacebookSDK.NET does a comparison in line 104 of LoginPage.xaml.cs with a simple Uri equality test
if (e.Uri == WebAuthenticationBroker.EndUri)
which fails to return true when the question mark appears in the middle. I expect Facebook will correct this on their end just because too much stuff breaks, but in the meantime a pretty clean fix is to get the FacebookClient sources from GIT instead of NuGet and change the comparison to this
UriBuilder clean = new UriBuilder(e.Uri);
clean.Query = "";
if (clean.Uri == WebAuthenticationBroker.EndUri)
The code will then run just fine, but this is seems ultimately to be Facebook's bug when checking the documentation on their developer site.
I hope this helps some others, I signed up for Stackoverflow just to make this post. :)
Use latest facebook sdk for windows phone. This issue got resolved in latest sdk. I am using Facebook.Client 0.8.2-alpha and its working great. I followed http://nuget.org/packages/Facebook.Client and http://facebooksdk.net/docs/phone/controls/login-ui-control
I guess the only way he did this was by downloading both projects from their official Github (Facebook and Facebook.Client) and reference them in your app instead of using the DLL that you can get from Nuget.
With both projects in hand, you can change this parameters on the Facebook.Client Project in the file FacebookSessionClient. Then build all the project and run.
However this solution didnt work for me too.

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.