phonegap social sharing button issue android - android

I'm trying to create an app with phonegap and I want to include a sharing button. I couldn't make it so I created a new empty project from phonegap. I just have the sample page displayed and nothing else, when I try it on my phone. Now i want to simply add a basic sharing button.
Following the instructions here : https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
I went to my project folder and just installed the plugin with the phonegap command.
Then in my index.html I simply added this :
<button onclick="window.plugins.socialsharing.share('Message only')">message only</button>
But when I click it, nothing happens.
I also tried the other given buttons and solutions but none works. Any ideas? I'm struggling with this for 2 days!
Thank you in advance for your answers :)

Have you followed this setup.
https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#manually
Add the following xml to all the config.xml files you can find
For IOS:
<feature name="SocialSharing"><param name="ios-package" value="SocialSharing" /></feature>
For Android
<feature name="SocialSharing"><param name="android-package" value="nl.xservices.plugins.SocialSharing" /></feature>
For Windows Phone
<feature name="SocialSharing"><param name="wp-package" value="SocialSharing"/></feature>
For sharing remote images (or other files) on Android, the file needs to be stored locally first, so add this permission to AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
For iOS, you'll need to add the Social.framework and MessageUI.framework to your project.
Click your project, Build Phases, Link Binary With Libraries, search for and add Social.framework and MessageUI.framework.2.
Grab a copy of SocialSharing.js, add it to your project and reference it in index.html:
<script type="text/javascript" src="js/SocialSharing.js"></script>
Download the source files for iOS and/or Android and copy them to your project.iOS: Copy SocialSharing.h and SocialSharing.m to platforms/ios//Plugins
Android: Copy SocialSharing.java to platforms/android/src/nl/xservices/plugins (create the folders)Window Phone: Copy SocialSharing.cs to platforms/wp8/Plugins/nl.x-services.plugins.socialsharing (create the folders)

Related

Not able to init through phonegap build. Phonegap Inapp billing

I am trying using this plugin(https://github.com/poiuytrez/AndroidInAppBilling). I added this in config.xml file and then uploaded it to phonegap build
<gap:plugin name="com.smartmobilesoftware.inappbilling">
<param name="BILLING_KEY" value="" />
</gap:plugin>
I did put my BILLING_KEY in the value above. But when I run the app. I am getting error like this
index 1 out of Range[0..1)
I tried console and it says key is undefined.
I send the key during init as in option like this
inappbilling.init(successHandler, errorHandler, {showLog:true,key:vkey});
where vkey contrain my Billing key string. Still I am not able to initialize the inAppbilling. Can anyone please tell what I am actually missing.
When I see my apk file. I can see the inappbilling.js file being included in the head. I can also see com.smartmobilesoftware.inappbilling directory with in the plugin.
Any kind of help will be greatly appreciated.
I found this answer on GitHub: The official PGB plugin for this repo is com.smartmobilesoftware.androidinappbilling

Phonegap Filesystem keeps saving to internal storage while there is an SD card

I'm having trouble using the phonegap file API. In my application I'm using the following piece of code to save images from the LocalStorage to the android device.
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
// If the folder does not exist create it
fileSys.root.getDirectory( myFolderApp, {
create:true, exclusive: false
},
function(directory) {
entry.moveTo(directory, newFileName, successMove, resOnError);
},
resOnError);
}
the variable myFolderApp contains the foldername that needs to be created. The problem is that even tough the android tablet has got an SD card inserted, the applicaton keeps creating the directory (and later saving the data) to the internal storage instead of the external SD card.
localFileSystem.PERSISTENT Should switch to sd card when one is available right?
When I log the directory.toURL() it's saying "cdvfile/localhost/persistent/mydirectory"
The native android camera application is saving it's images to the SD card which means the SD card is working properly.
I'm quite lost at this point. After hours of googeling I know the cordova file plugin has recently been updated, and therefore sometimes requires a different approach but I'm still stuck and can't seem to find a solution.
Hope someone can help me.
Thanks in advance,
Marco
Try changing in config.xml
<preference name="AndroidPersistentFileLocation" value="Internal" />
to
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
See the following discussion:
https://groups.google.com/forum/#!msg/phonegap/5UeZOBAz_DM/YlaGFJVCpv4J
We need to modify the AndroidManifest.xml file, however we will not do it manually. This is not a good practice as everytime you build your project, your changes will be lost.
Instead we are going to use the cordova-custom-config plugin, which allow you to modify the AndroidManifest.xml file from your config.xml file without problems. To install the plugin execute the following command in your command line :
cordova plugin add cordova-custom-config
# Or phonegap
phonegap plugin add cordova-custom-config
Fortunately, to enable this feature you need add only a property to the AndroidManifest.xml file. Using cordova-custom-config plugin, which allow you to use custom config blocks in your config.xml file of your cordova app, you need to add the following line in the config.xml file inside the tag :
<platform name="android">
<!-- Modify the android-manifest block and add the new property android:installLocation with value auto !-->
<preference name="android-manifest/#android:installLocation" value="auto" />
</platform>
Read more about step by step here.
Read more about the plugin here in the official repository here.

Phonegap - Load mp3 from www folder

I need to load an mp3 on iOS from the www folder next to my HTML. I'm using phonegap and my code is basically the same as the example from : http://docs.phonegap.com/en/2.0.0/cordova_media_media.md.html
Its working on iOS and android when I use an mp3 from the web but if I try to load one from the www then I am getting a window saying I can't use the ressource (on ios).
I added this in my config.xml :
<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/media" />
<gap:plugin name="org.apache.cordova.media" />
I am testing with the phonegap app for ios (http://app.phonegap.com/) from my phonegap server on windows and debuging with wienre. The rest of the app is working just the sound doesn't start.
I tried several different path :
"mySound.mp3"
"file://mySound.mp3"
"file:///mySound.mp3"
I also tried changing to an older phonegap version with no more luck.
Looking at the doc (same page as before) i should be able to just use the name of my file :
order of file search: When only a file name or simple path is
provided, iOS searches in the www directory for the file, then in the
application's documents/tmp directory:
var myMedia = new Media("audio/beer.mp3") myMedia.play() // first
looks for file in www/audio/beer.mp3 then in
/documents/tmp/audio/beer.mp3
I spent hours looking on internet and testing and i can't get that sound to start :/
Help would be much appreciated!
From what I know, iOS works with .wav file type. Maybe you should change your file type from .mp3 to .wav. Add the following to your config.xml
<plugin name="Media" value="CDVSound" />
iOS plays mp3 files. He only records in wav.

Android Phonegap plugin and google analytics

I am using phonegap plugin and I could not get it to work. In the plugin, there is a plugin.xml and may I know how this file should be set up.
I have mine configured as below and it does not work.
<platform name="android">
<config-file target="res/xml/config.xml" parent="plugins">
<feature name="GAPlugin" >
<param name="android-package" value="com.adobe.plugins.GAPlugin"/>
</feature>
</config-file>
<source-file src="src/com/learnchn/pinyin/GAPlugin.java"
target-dir="src/com/learnchn/pinyin" />
<source-file src="libs/libGoogleAnalyticsV2.jar"
target-dir="libs" />
</platform>
plugin.xml is a file that is meant to be read and executed by tools such as the plugman to install a plugin to a platform. If you are not using such a tool then you may try to do the steps manually. Basically insert <feature> to res/xml/config.xml and copy src files on <source-file> to target-dir.
However I doubt that the plugin.xml you have posted is valid. The value for "android-package" parameter should point to the plugin implementation. The value "com.adobe.plugins.GAPlugin" would suggest that there would be a corresponding source file or a library with that class name added as part of the installation. However the only file that is added with a close name is "com/learnchn/pinyin/GAPlugin.java" which has a different package name.
At first you have to build your project with phonegap. Navigate to the location where you want to create your project and do the following:
phonegap create test com.example.test Test
cd test
phonegap local build android
Now you have a working android project in your "platforms/android/" directory which you can import in eclipse. Download the GAPlugin and unzip it. Then just use plugman to install the Google Analytics Plugin.
plugman install --platform android --project (Path to your phonegap android project) --plugin (path to the GAPlugin)
Now everything should be set and the plugin is installed. The next step would be initializing the plugin in your index.html to track every page visit. Add the GAPlugin.js
<script type="text/javascript" src="GAPlugin.js"></script>
You should add the following code after you received the "deviceready" event.
document.addEventListener("deviceready", onDeviceReady, false);
var gaPlugin;
function onDeviceReady() {
gaPlugin = window.plugins.gaPlugin;
gaPlugin.init(successHandler, errorHandler, "UA-********-*", 10);
// Put this function everywhere you want to track something
gaPlugin.trackPage( nativePluginResultHandler, nativePluginErrorHandler, "index.html");
function successHandler() {}
function errorHandler() {}
function nativePluginResultHandler() {}
function nativePluginErrorHandler() {}
}
This approach worked for me. I'm using Phonegap 3.0 with the CLI.
Hope this fixes your problems ;)
If u want to add simple google Analytics setup then its quite easy just follow the below steps
1:- Add libGoogleAnalyticsV2.jar in libs folder 2:- Add analytics.xml file inside res->values, it binds the trackingid with the app,u can google for this file 3:-Add import com.google.analytics.tracking.android.easyTracker; in the activity file and use EasyTracker.getInstance().activityStart(this); in onCreate function.
Thats it, you are done with Google Analytics basic setup

Android Phonegap 2.2 Network Connection: Class Not Found

I recently upgraded my app from Phonegap 1.6 to 2.2.
I've refactored everything (ex Plugin --> CordovaPlugin) and I'm also using the new config.xml.
The app compiles and builds, however I constantly am getting an error in logcat and an error dialog box. The dialog says [ERROR] Error initializing Cordova: Class not found.
The logcat error is:
Line 6048 : Error initializing Network Connection: Class not found
What could I be missing?
The issue happens on multiple devices.
Update
I've already changed the config.xml for the network status plugin from Network Status to NetworkStatus. It reads: <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
I had this problem and made it go away by adding the following to the config.xml:
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
And adding this to the Manifest file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I originally took them out because I "knew" that my app wouldn't be using any communications. I had forgotten about the emulator "communicating" with the ADK.
I'll take these 2 lines out when I convert the project over to "production" so that the app is ready for Google Play.
I had this problem using phonegap 3.x and the problem turned out to be that phonegap hadn't properly installed the plugins, or they just messed up along the way. Basically when you install the plugins and build for a platform it takes the javascript files from plugins/org.apache.cordova.core.specific-plugin/www and puts them in platforms/android/assets/www/plugins/org.apache.cordova.core.specific-plugin/www and then it takes the Java files (or objective C for iOS) and puts them in platforms/android/src/org/apache/cordova/specificplugin
And all of this is specified by plugins/org.apache.cordova.core.specific-plugin/plugin.xml. If you look in a plugins.xml you should see something like:
<source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" />
So this tells you that in platforms/android/src/org/apache/cordova/networkinformation, there should be NetworkManager.java. And right that file can be copied from plugins/org.apache.cordova.core.network-information/src/android/NetworkManager.java
Now all of this is supposed to happen automatically without having to touch the platforms folder. But if it messes up you can fix it by copying the correct java files into the correct folders.
The following line in config.xml works for cordova 6.2 with android
<plugin name="cordova-plugin-network-information" value="org.apache.cordova.networkinformation"/>
The name should be the same as in what your plugin contains. You can find it in the your project folder at the following path plugins/name-of-the-plugin/package.json.
The value should be the package name for the plugin which can be found in the native implementation file.

Categories

Resources