all cordova plugins give undefined error - javascript

I am working on a cordova android app. I am trying to implement push notifications. I tried so many ways using ngcordova, using normal plugin and some other methods all tries give me pushNotification undefined error. But the plugins are being installed without any error.
Then I followed this tutorial and did exactly the same, but it gives
device is not defined
error in the console. I used ripple emulator to test this. I installed it in the phone too, But the same error. I am using angularjs inside. and using cordova version 5.2.0. can anyone point me in a direction, I am really trying hard for the past 4 days but no luck. Please help me.
update
I have correct setup of angular and cordova I believe, because I already built an version of my app with the same setup and pc, and released it in play store. This problems arise only if I add some plugins like push, device, etc. In app browser and splash screen plugins are working fine though.

Make sure to include cordova.js, but it need to be load after angular.js.
If you want, here's a working seed:
https://github.com/marioaleogolsat/cordova-angular-angularMaterial-seed
Just remember that some plugins can't be used in a emulation, so use cordova run --device to make sure that anything is working properly.

Hi It seems you have not done set up of Angular JS and Cordova properly.
Before doing push notifications. You must be ready with Angular JS and Cordova setup.
See below link:
Angular JS and Cordova setup
Follow above link and if it's done try to set up again push notifications.
Hope it helps you.

If Cordova is undefined you probably don't have it referenced in your index page. make sure you have this line.
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>

Related

cordova plugin's metadata value not updating

I am using ngcordova and ionic to develop one demo app.
But somehow i see /www/cordova_plugins.js this file metadata values never updated, and that is why i am having issues for social login.
module.exports.metadata =
// TOP OF METADATA
{}
above code stay same no matter if i add or remove plugin vice versa.
Cordova version
Dipeshs-Mac-mini:AppIonic Dipesh$ cordova -version
5.4.0
Ionic version
Dipeshs-Mac-mini:AppIonic Dipesh$ ionic -version
1.7.10
Plugin i am trying
http://ngcordova.com/docs/plugins/oauth/
But plugin seems working but somehow i got inappbrowser plugin not found but i have installed it.
And by debuging in deep i came to know that var cordovaMetadata = cordova.require("cordova/plugin_list").metadata; this code give empty array and that is reason plugin isn't working.
So if you guys have any idea share it with me so i can overcome this issues.
After some reading i found answer on my own.
Actually cordova new version might have some issues so downgraded cordova version to 5.3.3 and all seems working fine.

Check if a URL scheme is registered on iOS or Android in Cordova

I want to check if a particular app is installed and if it is installed, invoke it.
AFAIK, the way to do it is to check if the custom url scheme of the app is registered and use that url to launch the app.
Is there a way for me to do this in my Cordova app?
To be very specific I want to check if the Google Maps application is installed on iOS and if it is, launch it with its custom url else show the default Apple maps.
This url : https://developers.google.com/maps/documentation/ios/urlscheme : shows how to do it in Objective-C, but how do I do it in Javascript in my Cordova app?
I could not find any plugin to achieve the same. Other questions on SO deal with either doing this from a native app or JS on a regular website (in the browser). The most common work-around is to try launching and use a timeout to see if the app launch failed and still my app is running. This is pretty unclean. Access to the iOS API canOpenURL through JS would be best.
Hints?
Cordova does not ship with this feature. There is a plugin which implements it for iOS, though.
https://github.com/philbot5000/CanOpen
I did not find anything for Android yet, but I do not think this would be hard to do in native Android Code. Even if you are not proficient with Objective-C or Java and never intend to write fully native apps, you should learn some basics if you want to build apps with Cordova.
Small and simple plugins are really easy to do. Read the docs and have a look at the code of some simple plugins to see how it is done. For example the source code of the one above or of the one below is really simple and straightforward to understand:
https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin

Phonegap push notification with parse.com

Im looking for a way to implement push notification on a phonegap application using javascript and parse.com. I found this turorial for iOS
http://www.ladeezfirstmedia.com/2013/08/01/tutorial-part-5-push-it-real-good-with-push-notifications-using-corona-sdk-and-parse-com/
, which seems pretty straight forward, and this tutorial for android http://www.raymondcamden.com/index.cfm/2012/10/10/PhoneGap-Parsecom-and-Push-Notifications.
However, Im using cordova 3.3. and rather stay away from editing the AndroidManifest, which I need to do in the last tutorial. Can any one point me in the right direction, maybe to a tutorial where I can use cordova plugin and easily combine it with parse.com by using javascript for both iO and Android? Btw Im building my project locally in the terminal.
What I want is to notify the user, when its their turn in a game.
Have a look at this answer I've just posted, I've just got the Android Parse PNs working:
How do I get Parse.com Push Notifications working in a Cordova/Phonegap Android app?
It does require you to modify the AndroidManifest and some of the Java files as well, but not a lot. I can't find a plugin that works without doing some of the work myself.
You can use the plugin for iOS as well, you don't need to edit any of the iOS source code but will need to generate a certificate for iOS push notifications, as documented on Parse.
https://parse.com/tutorials/ios-push-notifications

phonegap 1.7.0 plugins android not working

I'm programming an android app using Applicationcraft, but then I need to create my own plugin for a certain requirement. So I downloaded my app from applicationcraft, then compile it manual using phonegap 1.7.0, but I'm having a problem with my plugin. I have followed every steps in this tutorial, but whenever I use my plugin in a test device I always get this error:
Cannot call method "myfunction" of undefined.
Function: callingFunction
I also consult another question here, but I still having the same problem.
Can anybody tell me what are the possible solutions? Or point me to the right direction (any tutorial for making plugin for PhoneGap 1.7.0). Thanks.
No need, I've already found it here.

Trouble with iOS and PhoneGap

Just started trying to adapt my html, css, javascript files to iOS using PhoneGap (I've also tried NimbleKit but the result is the same). I have a web app that I originally wrote for the Blackberry Playbook. The app works fine on the Playbook and in Chrome and Safari. However, when I try and run it through XCode with PhoneGap, the app displays on the simulator but does not seem to properly run the database coding (at least I think that is the problem). I do not get any build errors.
From the documentation, NimbleKit seems to just support its own internal SQLite, but PhoneGap seems to support WebDB, which is what my database is written in.
Finally, the simulator doesn't seem to run some global variables I have (I know, I know, don't use global variables) although that could be because they appear just after my DB initialization at the beginning of my javascript file.
Any thoughts or points in the right direction would be very helpful. Even if it is to some documentation which can help me debug the app in the iOS sim.
Thanks in advance.
Cold your problem be related to this?
http://phonegap.com/2012/04/18/ios-5-1-and-the-embedded-uiwebview-with-cordova/
I was facing a similar problem with PhoneGap and iOS Simulator last week,
all the code i wrote seem to have no problem,
anyway i tried this remote web inspector, and tried to create a database remotely using Safari Javascript Console,
bottom line I found that I was not able to create web database using iPhone Simulator,
looks like you need to deploy your app onto your device to make use of it.
I might be wrong, but that was what I found.

Categories