phonegap navigator.connection is undefined - ios

I've got a problem using Phonegap.
I've created a Test application using console:
phonegap create ProjectTest
cordova platform add ios
cordova build
Then opened generated Xcode project and added new line to onDeviceReady function:
onDeviceReady: function() {
app.receivedEvent('deviceready');
// MY TEST
alert(navigator.connection);
}
Also i've added this line to my config.xml:
<plugin name="NetworkStatus" value="CDVConnection" />
So, result in alert is 'undefined'......
I just need to test the connection, using navigator.connection.type
Using MacBook and Xcode 4.6.3

Same issue here. I was testing my code after these steps. create, add platform ios, add plugin blabla. When you do like this, its not working. You have to say
$ cordova build ios
or
$ phonegap build ios
after that, its creating new files about plugins and its working. Hope that help you too.
(cordova 3.3.0)

I was having a similar issue, and was able to answer my own question after a bunch of research.
See this StackOverflow post for the solution.

You should add connection plugin first

Related

how to add plugin without cli in cordova 3.5.0 iOS

I am not using cli for my cordova project ,i got the cordova 3.5.0 project from there site and integrated with my project.All the custom plugins created by me is working fine.But the API's like device is not accessible.I have added the CDVDevice to config.xml but still i can't able to access the device object.
So please help me to solve this problem.
In order to correctly working the Cordova requires you to have cordova_plugins.js file near the cordova.js. That file contains registration of the JS API.
The easiest part is use Plugman to install plugins inside your custom project, that way, it will handle all work on creation of cordova_plugins.js.
Official Cordova documentation for the Plugman
See the possible related answer Cordova 3.5 embedded webview with plugins where I put more insights about how you could modify cordova_plugins.js in case you desperately need this, but I would recommend you to use Plugman.

Phonegap 3.5 on iOS navigator.connection is undefined

I am porting an old Phonegap 2 app to Phonegap 3.5
I created a new project using the CLI. Added the core plugins, including network-information.
Then I copied my html, css and javascript files.
I am now using XCode to further develop the app.
The app starts on the ios simulator but gets stuck when calling navigator.connection in the code.
I checked that the plugin files are there at platforms/ios/[project name]/plugins/org.apache.cordova.network-information :
CDVConnection.h
CDVConnection.m
CDVReachability.h
CDVReachability.m
The feature tag is there at the config.xml
I found this question Cordova 3 - iOs - navigator.connection Undefined which is the more similar I found to what I am experiencing, but it has not helped me solve the issue.
What else can I check? I need this plugin working. The migration from old phonegap has been a nightmare so far.
Thanks for any help.
I solved this by uninstalling the plugin, and installing it again. Even though everything looked ok, this solved the issue.

InAppBrowser not launching

I've installed Phonegap using the npm and my app is working great, except when I call window.open to launch a website it does not give me the footer with the done button so my app get's stuck on the called web page.
I am using XCode to build an ios app.
I've used npm to add the InAppBrowser plugin. It added the to to the config.xml.
I've added the site to my whitelist in config.xml. The site opens fine, just without the done button/footer.
It added the InAppBrowser plugin entry to:
/#myapp#/platforms/#platform#/www/cordova_plugins.js
It added the InAppBrowser plugin folder in /#myapp#/platforms/#platform#/plugins/
The related SRC files for InAppBrowser are in the platform folder as well
(for example IOS plugin src files are: /#myapp#/platforms/#platform#/#appname#/Plugins/)
I added a console.log function to InAppBrowser.js to confirm that the plugin is loaded, but it does not generate a log entry.
I've tried many things to get the footer/done button to show without any success, but I seem to be missing something here.
I solved this problem by recreating the Xcode project using cordova (instead of phonegap). I went through all of the solutions several times with no luck, so I used the terminal to build a new cordova project, added the InAppBrowser to the project, then copied my code and assets from the old project to the new one. Launched the app on my ipad and it all worked just fine.
I don't suspect it's a problem with Phonegap 3.1.0. I think there was a project issue that kept it from working and starting over with a clean project did the trick.
All is well.
One note is that I saw postings that reported cordova interrupts the console.log function, so be careful with that. Alerts work just fine.

Settings tool plugin in cordova +ios app development

I am creating my app with cordova 2.1.0 framework. I want to add an option in settings page of the device(IPOD/Iphone/Ipad) with a name value pair. So, basically on deployment, the settings tool should get populated with a new option. Is there a cordova plugin to establish this?
Maybe this one is of help ?
https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/ApplicationPreferences
Also note that you will have to create a Settings Bundle outside Cordova, read up here: http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/UserDefaults/Preferences/Preferences.html

Add facebook iOS SDK without Xcode for a Phonegap Build app

I've been able to successfully build my iOS app without using Xcode. My app is a collection of HTML, CSS, and Javascript, along with my config.xml that I'm able to compile with Phonegap Build.
The app's basic functionality has been tested on iPhones and works well, but now I want to add a social layer to the app with the FacebookConnect plugin for Phonegap Build. However, the documentation on GitHub requires the app to be setup in Xcode.
Without using Xcode, is there a way to download the SDK (not as a .pkg) and add it to my project files that I upload to Phonegap Build to complile? If so, where do I get the files, which files do I need, and where do I include these files in my project structure?
Here is my current project structure:
-config.xml
-index.html
-includes
--css
--js
Perhaps there is a way of doing this with GitHub, but I've never done pull requests or anything like that. I simply work in my text editor and am not sure how to pull from GitHub.
Phonegap Build Plugins
Thank you for any help you can offer on this!
I have successfully implemented the FacebookConnect Plugin for Phonegap Build on Windows without Xcode.
I recommend just following the instructions on the Phonegap Build Plugins page and ignore the instructions on the GitHub page (which talks about Xcode and other things you don't need for the Build plugin). They have now updated the GitHub page instructions to direct Phonegap Build users away from the GitHub instructions and over to the Phonegap Build Plugins page.
For Step 1 (Setting your app up on facebook), select Native iOS App and the Bundle ID is the same as your "id" in your config.xml (i.e. com.company.appname) and you can set the App Store IDs to "0" while testing.
For Step 2, make sure you use facebook-js-sdk.js. At one time there was a typo.
A good way to test things out is to paste the content of the example Simple app on GitHub into a new index.html file and upload it with your normal config.xml file to Phonegap Build . I did this for one build on my app and then after I tested it, just uploaded my normal index.html file. The only change you will need to make in the index.html of the Example app is to put your Facebook App ID at the bottom in the FB.init function. I also changed response.session to response.authResponse to match the Facebook JS SDK, but I'm not sure if that is necessary.
Be sure to update your config.xml file with everything mentioned in Step 3. I also added the following code:
<access origin="http://m.facebook.com" />
<access origin="http://graph.facebook.com" />
<access origin="http://api.facebook.com" />
<access origin="http://fbcdn.net" subdomains="true" />
<access origin="http://akamaihd.net" subdomains="true" />
The above code is not necessary if you have the following in your config.xml file already:
<access origin="*" />
The FacebookConnect plugin is using the Facebook JS SDK, which you can learn more about here: https://developers.facebook.com/docs/reference/javascript/.
Also, one other issue I ran into that the Phonegap Build Team is working on is that when asking for permissions, you cannot just ask for the Basic Permissions by leaving off the scope option. For now, you must include at least one scope option for the login function to work.
function fbLogin () {
FB.login(function(response) {
if (response.authResponse) {
alert('User Login Success!');
} else {
alert('User cancelled login or did not fully authorize.');
}
}, { scope: "email" });
}
Most developers probably want to ask for more than the Basic Permissions, so this shouldn't be that big of an issue.
My responses above are from discussions about the Facebook Plugin over on the Phonegap Build Support Site. You can learn more about the plugin and current issues and solutions there.
It took me a little while to figure this stuff out, so hopefully this will help others save some time.

Resources