top of page

Grupo

Открытая·66 пользователей
Bonnetias Williams
Bonnetias Williams

Phonegap Facebook Share Plugin Android


I have used "SocialSharing" plugin in my phonegap application to share on facebook. It is working fine if facebook application is installed on android device. But if application is not installed it gives me error like "Share via Twiiter error: com.android.bluetooth,com.android.mms".




phonegap facebook share plugin android



window.plugins.socialsharing.shareViaFacebook("Sample text", null, null, function() console.log('Share via Facebook success'), function(errormsg)console.log('Share via Facebook error: '+errormsg));


platforms/android and platforms/ios contain example projects and all the native code for the plugin for both Android and iOS platforms. They also include versions of the Android and iOS Facebook SDKs. These are used during automatic installation.


This is a fork from jeduan/cordova-plugin-facebook4, where i excluded the com.google.zxing package (that is used by facebook sdk for qr scaning) that is causing the issue "Multiple dex files define Lcom/google/zxing/BarcodeFormat"


WARNING: The purpose of this tutorial is to serve as a deep dive into how a Cordova plugin is utilised by Capacitor and, through understanding this process, how we can attempt to configure plugins correctly for Capacitor. It goes into a lot of technical detail, and if you're only interested in getting the cordova-plugin-facebook4 plugin up and running you might find it frustrating. I have a much more brief tutorial that covers setting up cordova-plugin-facebook4 in Capacitor here: Using Cordova Plugins that Require Install Variables with Capacitor.


NOTE: To really solidify these concepts, you might find it useful to set up your own Capacitor project and follow along in Android Studio. It is also helpful to have the source code for the cordova-plugin-facebook4 plugin to reference on GitHub, and even the source code for Capacitor as well.


Consider the cordova-plugin-facebook4 plugin that is used to access the Facebook SDK in Cordova projects (and with the techniques we will cover in this tutorial... Capacitor projects too). Most of the functionality for this plugin is contained within the src/ios and src/android folders. It is in these folders that the native code to make the Facebook SDK work for both iOS and Android is contained, therefore you will find a bunch of Objective-C and Java code.


If we inspect the native Android project inside of our Capacitor project we would find that the ConnectPlugin.java file that was inside of the src/android folder of the plugin is now located at:


The src indicates the JavaScript file in the cordova-plugin-facebook4 plugin that we are working in, in this case the one located at www/facebook-native.js, that will be loaded by the browser to export the methods that the plugin makes available to the application. This file exports a bunch of methods like: getLoginStatus, showDialog, login, logout, and so on. These are the methods that we would call from within our application to access the native functionality. A clobbers target of facebookConnectPlugin here means that these methods would be made available under the window.facebookConnectPlugin namespace. This means that within our application we would be able to make a call to window.facebookConnectPlugin.getLoginStatus() to access the functionality.


NOTE: Capacitor will also look for entries with a target of AndroidManifest.xml and add any configurations supplied there to the AndroidManifest.xml file that is automatically created at capacitor-cordova-android-plugins/src/main/AndroidManifest.xml. This file will automatically be merged with any other AndroidManifest.xml files from other modules in the project (including the main manifest file at app/src/main/AndroidManifest.xml).


The source-file entry in Cordova-land points to a file in the plugin that should be executed. In this case, it wants to copy the facebookconnect.xml file to the res/values directory. It then uses the config-file entries to target the file that was just created and set up some strings/variables inside of it for the application to use. Again, that is what is happening with Cordova, but how does Capacitor handle this?


Into the AndroidManifest.xml within the capacitor-cordova-android-plugins module (along with the configurations for any other plugins that target AndroidManifest.xml) and then those values will be merged with the Android projects main AndroidManifest.xml file. Notice that the and tags that will be added to the manifest reference those variables that we just added to strings.xml.


You can see above that implementation "com.facebook.android:facebook-android-sdk:5.13.0" has been added automatically after installing this plugin. But, wait a minute... how did it know to replace $FACEBOOK_ANDROID_SDK_VERSION with 5.13.0?


By default, Capacitor apps only allow to share files from caches folder. To make other Android folders shareable, they have to be added in android/app/src/main/res/xml/file_paths.xml file. Check the Specifying Available Files section in FileProvider docs for the available locations.


This page explains everything: github.com EddyVerbruggen/SocialSharing-PhoneGap-Plugin/blob/master/README.md#4a-usage-on-ios-and-android# PhoneGap / Cordova Social Sharing plugin[![NPM version][npm-image]][npm-url][![Downloads][downloads-image]][npm-url][![Twitter Follow][twitter-image]][twitter-url][npm-image]: -plugin-x-socialsharing.svg[npm-url]: -plugin-x-socialsharing[downloads-image]: -plugin-x-socialsharing.svg[twitter-image]: =social&label=Follow%20me[twitter-url]: [@EddyVerbruggen]( ), [read my blog about this plugin]( -services.nl/phonegap-share-plugin-facebook-twitter-social-media/754)[![paypal]( _US/i/btn/btn_donate_SM.gif)]( -bin/webscr?cmd=_donations&business=eddyverbruggen%40gmail%2ecom&lc=US&item_name=cordova%2dplugin%2dsocialsharing&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)Every now and then kind folks ask me how they can give me all their money. So if you want to contribute to my pension fund, then please go ahead :) This file has been truncated. show original


Hi Manuel,Hard to say what can be wrong in your case. Maybe the socialsharing plugin is not correctly added to your app?Could you please write to support[at]uncategorized-creations.com with some more information about your Phonegap version, Cordova plugins versions and what happens exactly when you click the share button inside your compiled app? Thanks.Regards


Part Two: Install Facebook SDKThere are several plugins to choose from, I went with cordova-plugin-facebook4. NOTE: The current version (1.9.1) is incompatible with Meteor because of this issue. You must downgrade to 1.7.4 (or follow one of the other fixes listed in GitHub)


You may have heard of PhoneGap, and wonder how it relates to Cordova. PhoneGap is a product name used by Adobe since 2011, when they acquired a company called Nitobi, the original creators of what is now the Cordova project. When Adobe donated the code to Apache in 2012 to ensure a more open governance model, the open source project was rebranded as Cordova. PhoneGap is now one of the distributions of Cordova, on a par with other distributions like Ionic, Telerik, Monaca, or Intel XDK. These distributions mainly differ in tooling and integration with cloud services, but they share the underlying platform and plugins. Meteor could also be considered a Cordova distribution.


Some Cordova plugins require certain parameters to be set as part of the build process. For example, com-phonegap-plugins-facebookconnect requires you to specify an APP_ID and APP_NAME. You can set these using App.configurePlugin in your mobile-config.js.


If you're using Adobe's PhoneGap Build Cloud service to build your app and using another plugin that references "Google Play services" or the "Android Support library" (v4 or v13) you will need to remove the duplicate libraries. This includes dex errors such as com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; Please check if you have any of the plugins below in your config.xml and follow the instructions for them below.


If you have com.phonegap.plugins.pushplugin we recommend remove this as having 2 push notification providers can create issues. If you must have this plugin along side OneSignal you will to use the new phonegap-plugin-push plugin which replaced it.NOTE: The phonegap-plugin-push will cause no push token issue with OneSignal on iOS so you must remove it if you need iOS support.


The Unexpected call to didRegisterForRemoteNotificationsWithDeviceToken, ignoring comes from the phonegap-plugin-push and is known to interfere with other push notifications plugins. Please remove it by running cordova plugin rm phonegap-plugin-push and OneSignal should start working in your project.


If you were using the cordova-plugin-androidx-adapter plugin to migrate the Camera's legacy Android Support Library references to the new AndroidX references, it can be removed unless your project is using other third-party plugins that have not migrated to AndroidX.


In our last plugins release, we deprecated cordova-plugin-compat since it got integrated into cordova-android@6.3.0. So for this release cycle, we have removed the dependency from plugins that were relying on it and gave the plugins a major version jump. The follow plugins have dropped cordova-plugin-compat: cordova-plugin-camera, cordova-plugin-contacts, cordova-plugin-file, cordova-plugin-geolocation, cordova-plugin-media, and cordova-plugin-media-capture.


Google recently sent out warnings to everyone who uses cordova-plugin-geolocation about having to include android.hardware.location.gps to their AndroidManifest.xml. We updated cordova-plugin-geolocation plugin to auto add this setting to your project's AndroidManifest.xml when installing the plugin. This means that the geolocation plugin will only work on android devices that have a GPS. Let us know if this restriction affects you negatively. 350c69d7ab


https://soundcloud.com/constirodi1979/sims-4-tool-mod-download

О группе

Bem-vindo ao grupo! Você pode se conectar com outros membros...

Участники

  • Eurico Reynolds
  • Андрй Федорчук
    Андрй Федорчук
  • Андрій
    Андрій
  • Andrew Ferk
    Andrew Ferk
Página do Grupo: Groups_SingleGroup
bottom of page