while trying to create a push Notification using GCM Per device or a group of devices - we are trying to use Onesignal for registration of our android users and getting an undefined error.
the code is written on JS and then build using Phonegap and realesed as an APK for android, while debugging it we get "windwos.onesignal undefined"
any lead or help would be appriciated
Thank you
(can't post the Chrome debugger message rep 10 is requered :-) )
Is windwos.onesignal exactly what you have in your code? Or is this a typo in your post?
All calls to OneSignal should be called by with window.plugins.OneSignal.
Example:
window.plugins.OneSignal.sendTag("key1", "value1");
Check to make sure window.plugins is defined where you're calling OneSignal. It should be called from your onDeviceReady function or add a 'deviceready' listener if you don't have this function. Double check your code with OneSignal's Cordova/PhoneGap install instructions.
You can also send your APK to support#onesignal.com and we can help debug your issue.
Follow the documentation here Make sure you add plugin
> cordova plugin add onesignal-cordova-plugin
And try building it locally.
>ionic build android
If it works locally there is some issue with you config file.Specify version of plugin in config file. Check your installed plugin version.
<plugin name="com.onesignal.plugins.onesignal" spec="1.9.0" source="pgb" />
Hope this helps !
Related
I am new to all of this, so I am probably missing something pretty obvious, but I am trying to change the userAgent string in an application I am building with Cordova. Based upon the documentation at the Cordova website, it would appear that I should only need to add the following to my config.xml file:
preference name="OverrideUserAgent" value="My string value here"
So I included this line in my config.xml and then added this code to my javascript in my cordova app:
var ua = navigator.userAgent;
alert(ua);
I then build the project and install it on my android phone. However, when I run the app I get the same userAgent reported back by my alert regardless of whether I included preference name="OverrideUserAgent" value="My string value here" in the config.xml or not. I am using version 5 of Cordova (5.3.1 I believe) and this config.xml fix was listed in the documentation for version 5.1.1 on the Cordova website.
I have also seen another possible fix on stackoverflow in the following post:
Change PhoneGap / Cordova User-Agent for AJAX
Specifically I am looking at the response that recommends:
put this in your onCreate method: (after super.init();)
super.appView.getSettings().setUserAgentString("Your own agent string");
I am sorry to ask such a basic question, but how to I carry this out? Is it possible to do this while still using the Cordova CLI or do I need to import the project into Android studio first? Where exactly do I find the onCreate method that I need to modify.
Thank you for any help you may be able to offer.
i have a working PhoneGap/Cordova Project Ver 3.5.
i try to work with GA with this plugin, But without success:
https://github.com/danwilson/google-analytics-plugin
i success to install the plugin via this command:
cordova plugin add https://github.com/danwilson/google-analytics-plugin.git
when i try the usage the plugin it faild.
for example:
analytics.startTrackerWithId('UA-XXXX-YY') // UX-2323-23 for example
Any "analytics" function that i try to use fail with error:
"analytics is not defind"
i try via local server - get "analytics is not defind"
i try in simulator - get empty and white screen
i try on Real Device and also get empty and white screen
Please Help :)
Thanks,
Chen.R
First, provide access to external URL using in config.xml <access origin="*" /> then
Put this analytics.startTrackerWithId('UA-XXXX-YY') into onDeviceReady function.
And then you can write your own page names like analytics.trackView('page name');
When you are on the google analytics account, please check the date and time set for view report on right side corner.
Has anyone gotten the clipboard plugin to work with "PhoneGap Build"?
I can't get it to work. I'm currently useing phonegap 3.1.0
My app is for android and IOS. I've only tested the clipboard plugin on android so far, and it isn't working.
in my config.xml:
<gap:plugin name="com.verso.cordova.clipboard" />
in my javascript:
window.plugins.clipboard.copy('some text',function(){alert('success');},function(response){alert('error:' + response);});
window.plugins.clipboard.paste(function(text){alert('paste success:' + text);},function(response){alert('paste error:' + response);});
The way I have it above, the script runs, but for both the copy and paste calls, the error function is executed and the response is "Class not found".
I have tried the above call window.plugins.copy, cordova.plugins.copy
both of those just cause the script to abort.
phonegap is loading just fine and the deviceready function has already fired before I attempt the above calls.
Under the plugins tab on the phonegap build webpage for my app:
Installed 3rd Party Plugins
com.verso.cordova.clipboard 0.1.0
This appears to be unrelated to the copy/paste plugin. In phonegap 3.1 you have to reference all the phonegap plugins you want to use. In this case, I'm guessing you have a function that checks if the user has an internet connection? If so, you need to add to your config.xml
We are using Phonegap 3.1.0-0.15.0 and the application chocked when trying to access location information.
Works fine in iOS however the App chock on Android
We are using:
navigator.geolocation.getCurrentPosition(app.location.onSuccess, app.location.onError);
and we also tried:
var geo = cordova.require('cordova/plugin/geolocation');
geo.getCurrentPosition(app.location.onSuccess, app.location.onError);
The logcat mentioned the following:
Could not find cordova.js script tag. Plugin loading may fail. at file:///android_asset/www/phonegap.js:1511
Uncaught module cordova/plugin/geolocation not found at file:///android_asset/www/phonegap.js:56
The plugin was added using:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
Are we doing something wrong ?
Thank you in advance
/Edwardo.
Just to answer my own questions. I removed all the plugins manually and then add them (including the problematic geolocation plugin) using the following command:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
That solved my issue.
Edward.
I have a problem using the Facebook Connect plugin with PhoneGap.
I have added this line to file plugins.xml:
<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" />
And this include on in file FbDialog.java:
import com.phonegap.helloworld.R;
I have these files on src:
com
/facebook/android/
AsyncFacebookRunner.java
DialogError.java
Facebook.java
FacebookError.java
FbDialog.java
Util.java
/phonegap/
facebook/ConnectPlugin.java
helloworld/HelloPhoneGapActivity.java
The ressources files close and the icon is copied. In HTML, I include some JavaScript code:
cordova-1.6.1.js
cdv-plugin-fb-connect.js
facebook_js_sdk.js
I use the default HTML example with my appId.
When I run application on my Android phone, a dialog says:
Cordova Facebook connect plugin fail on init!
and
Cordova Facebook connect plugin fail on auth.status!
If I click the login bouton, the dialog says:
Cordova Facebook connect plugin fail on login!Class not found
And the Eclipse console log is:
I tried to install this with the officiel Git readme and the
tutorial Add Facebook login to PhoneGap/Cordova Android app Easiest way.
When I compile the application, I don't get the error.
How do I fix this problem?
After the switch to Cordova, everything got renamed. You need the new class location:
<plugin name="org.apache.cordova.facebook.Connect" value="org.apache.cordova.facebook.ConnectPlugin" />
You'll have to put your plugin java (back?) to the correct location as well in org/apache/cordova/facebook/ .
Unfortunately, the error for this is pretty vague, but you can see it if you know what to look for. You can see in your logs the line with Message=Class not found in it. It would be better if this line had the name of the class. This error happens when you call the JS for a plugin, but then the right class name can't be found in the plugins.xml file. This is also why you notice that any call fails the same way.
Verify that android studio isn't giving an error like:
A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
If so, then edit androidmanifest. See: A valid Facebook app id must be set in the AndroidManifest.xml