Giter VIP home page Giter VIP logo

cordova-plugin-facebook-connect's Introduction

cordova-plugin-facebook-connect

Use Facebook SDK in Cordova projects

Table of contents

Installation

See npm package for versions - https://www.npmjs.com/package/cordova-plugin-facebook-connect

Make sure you've registered your Facebook app with Facebook and have an APP_ID https://developers.facebook.com/apps.

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"

As the APP_NAME is used as a string in XML files, if your app name contains any special characters like "&", make sure you escape them, e.g. "&".

If you need to change your APP_ID after installation, it's recommended that you remove and then re-add the plugin as above. Note that changes to the APP_ID value in your config.xml file will not be propagated to the individual platform builds.

Installation Guides

Usage

This is a fork of the official plugin for Facebook in Apache Cordova that implements the latest Facebook SDK. Unless noted, this is a drop-in replacement. You don't have to replace your client code.

The Facebook plugin for Apache Cordova allows you to use the same JavaScript code in your Cordova application as you use in your web application.

Sample Repo

If you are looking to test the plugin, would like to reproduce a bug or build issues, there is a demo project for such purpose: cordova-plugin-facebook-connect-lab.

Compatibility

  • Cordova >= 5.0.0
  • cordova-android >= 9.0.0
  • cordova-ios >= 6.0.0
  • cordova-browser >= 3.6

Facebook SDK

This plugin use the SDKs provided by Facebook. More information about these in their documentation for iOS or Android

Facebook SDK version

This plugin will always be released for iOS and for Android with a synchronized usage of the Facebook SDKs.

Graph API version

Please note that this plugin itself does not specify which Graph API version is used. The Graph API version is set by the Facebook SDK for iOS and Android (see Facebook documentation about versioning)

API

Get Application ID and Name

facebookConnectPlugin.getApplicationId(Function success)

Success function returns the current application ID.

facebookConnectPlugin.getApplicationName(Function success)

Success function returns the current application name.

Set Application ID and Name

By default, the APP_ID and APP_NAME provided when the plugin is added are used. If you instead need to set the application ID and name in code, you can do so. (You must still include an APP_ID and APP_NAME when adding the plugin, as the values are required for the Android manifest and *-Info.plist files.)

facebookConnectPlugin.setApplicationId(String id, Function success)

Success function indicates the application ID has been updated.

facebookConnectPlugin.setApplicationName(String name, Function success)

Success function indicates the application name has been updated.

Note that in order to dynamically switch between multiple app IDs on iOS, you must use the OTHER_APP_SCHEMES variable and specify each additional app ID you will use with setApplicationId separated by a comma, e.g.

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable OTHER_APP_SCHEMES="fb987654321,fb876543210,fb765432109"

Login

facebookConnectPlugin.login(Array strings of permissions, Function success, Function failure)

Success function returns an Object like:

{
	status: "connected",
	authResponse: {
		accessToken: "<long string>",
		data_access_expiration_time: "1623680244",
		expiresIn: "5183979",
		userID: "634565435"
	}
}

Failure function returns an Object like:

{
	errorCode: "4201",
	errorMessage: "User cancelled"
}

Limited Login (iOS Only)

facebookConnectPlugin.loginWithLimitedTracking(Array strings of permissions, String nonce, Function success, Function failure)

Success function returns an Object like:

{
	status: "connected",
	authResponse: {
		authenticationToken: "<long string>",
		nonce: "foo",
		userID: "634565435"
	}
}

Failure function returns an Object like:

{
	errorCode: "4201",
	errorMessage: "User cancelled"
}

See the Facebook Developer documentation for more details.

Logout

facebookConnectPlugin.logout(Function success, Function failure)

Get Current Profile

facebookConnectPlugin.getCurrentProfile(Function success, Function failure)

Success function returns an Object like:

{
	userID: "634565435",
	firstName: "Woodrow",
	lastName: "Derenberger"
}

Note: The profile object contains a different set of properties when using Limited Login on iOS.

Failure function returns an error String.

Check permissions

facebookConnectPlugin.checkHasCorrectPermissions(Array strings of permissions, Function success, Function failure)

Success function returns a success string if all passed permissions are granted.

Failure function returns an error String if any passed permissions are not granted.

Get Status

facebookConnectPlugin.getLoginStatus(Boolean force, Function success, Function failure)

Setting the force parameter to true clears any previously cached status and fetches fresh data from Facebook.

Success function returns an Object like:

{
	authResponse: {
		accessToken: "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn",
		data_access_expiration_time: "1623680244",
		expiresIn: "5183738",
		userID: "12345678912345"
	},
	status: "connected"
}

For more information see: Facebook Documentation

Check if data access is expired

facebookConnectPlugin.isDataAccessExpired(Function success, Function failure)

Success function returns a String indicating if data access is expired.

Failure function returns an error String.

For more information see: Facebook Documentation

Reauthorize data access

facebookConnectPlugin.reauthorizeDataAccess(Function success, Function failure)

Success function returns an Object like:

{
	status: "connected",
	authResponse: {
		accessToken: "<long string>",
		data_access_expiration_time: "1623680244",
		expiresIn: "5183979",
		userID: "634565435"
	}
}

Failure function returns an error String.

For more information see: Facebook Documentation

Show a Dialog

facebookConnectPlugin.showDialog(Object options, Function success, Function failure)

Example options - Share Dialog:

{
	method: "share",
	href: "http://example.com",
	hashtag: '#myHashtag',
	share_feedWeb: true, // iOS only
}

iOS

The default dialog mode is FBSDKShareDialogModeAutomatic. You can share that by adding a specific dialog mode parameter. The available share dialog modes are: share_sheet, share_feedBrowser, share_native and share_feedWeb. Read more about share dialog modes

Share Photo Dialog:

{
	method: "share",
	photo_image: "/9j/4TIERXhpZgAATU0AKgAAAA..."
}

photo_image must be a Base64-encoded string, such as a value returned by cordova-plugin-camera or cordova-plugin-file. Note that you must provide only the Base64 data, so if you have a data URL returned by something like FileReader that looks like "data:image/jpeg;base64,/9j/4TIERXhpZgAATU0AKgAAAA...", you should split on ";base64,", e.g. myDataUrl.split(';base64,')[1].

Here's a basic example using the camera plugin:

navigator.camera.getPicture(function(dataUrl) {
  facebookConnectPlugin.showDialog({
    method: 'share', 
    photo_image: dataUrl
  }, function() {
    console.log('share success');
  }, function(e) {
    console.log('share error', e);
  });
}, function(e) {
  console.log('camera error', e);
}, {
  quality: 100, 
  sourceType: Camera.PictureSourceType.CAMERA, 
  destinationType: Camera.DestinationType.DATA_URL
});

Game request:

{
	method: "apprequests",
	message: "Come on man, check out my application.",
	data: data,
	title: title,
	actionType: 'askfor',
	objectID: 'YOUR_OBJECT_ID', 
	filters: 'app_non_users'
}

Send Dialog:

{
	method: "send",
	link: "http://example.com"
}

For options information see: Facebook share dialog documentation Facebook send dialog documentation

Success function returns an Object or from and to information when doing apprequest.

Failure function returns an error String.

The Graph API

facebookConnectPlugin.api(String requestPath, Array permissions, String httpMethod, Function success, Function failure)

Allows access to the Facebook Graph API. This API allows for additional permission because, unlike login, the Graph API can accept multiple permissions.

Example permissions:

["public_profile", "user_birthday"]

httpMethod is optional and defaults to "GET".

Success function returns an Object.

Failure function returns an error String.

Note: "In order to make calls to the Graph API on behalf of a user, the user has to be logged into your app using Facebook login, and you must include the access_token parameter in your requestPath. "

For more information see:

Events

App events allow you to understand the makeup of users engaging with your app, measure the performance of your Facebook mobile app ads, and reach specific sets of your users with Facebook mobile app ads.

Activation events are automatically tracked for you in the plugin.

Events are listed on the insights page

Log an Event

logEvent(String name, Object params, Number valueToSum, Function success, Function failure)

  • name, name of the event
  • params, extra data to log with the event (is optional)
  • valueToSum, a property which is an arbitrary number that can represent any value (e.g., a price or a quantity). When reported, all of the valueToSum properties will be summed together. For example, if 10 people each purchased one item that cost $10 (and passed in valueToSum) then they would be summed to report a number of $100. (is optional)

Log a Purchase

logPurchase(Number value, String currency, Object params, Function success, Function failure)

NOTE: Both value and currency are required. The currency specification is expected to be an ISO 4217 currency code. params is optional.

Manually log activation events

activateApp(Function success, Function failure)

Data Processing Options

This plugin allows developers to set Data Processing Options as part of compliance with the California Consumer Privacy Act (CCPA).

setDataProcessingOptions(Array strings of options, String country, String state, Function success, Function failure)

To explicitly not enable Limited Data Use (LDU) mode, use:

facebookConnectPlugin.setDataProcessingOptions([], null, null, function() {
  console.log('setDataProcessingOptions success');
}, function() {
  console.error('setDataProcessingOptions failure');
});

To enable LDU with geolocation, use:

facebookConnectPlugin.setDataProcessingOptions(["LDU"], 0, 0, function() {
  console.log('setDataProcessingOptions success');
}, function() {
  console.error('setDataProcessingOptions failure');
});

To enable LDU for users and specify user geography, use:

facebookConnectPlugin.setDataProcessingOptions(["LDU"], 1, 1000, function() {
  console.log('setDataProcessingOptions success');
}, function() {
  console.error('setDataProcessingOptions failure');
});

For more information see: Facebook Documentation

Advanced Matching

With Advanced Matching, Facebook can match conversion events to your customers to optimize your ads and build larger re-marketing audiences.

setUserData(Object userData, Function success, Function failure)

  • userData, an object containing the user data to use for matching

Example user data object:

{
	"em": "[email protected]", //email
	"fn": "john", //first name
	"ln": "smith", //last name
	"ph", "16505554444", //phone number
	"db": "19910526", //birthdate
	"ge": "f", //gender
	"ct": "menlopark", //city
	"st": "ca", //state
	"zp": "94025", //zip code
	"cn": "us" //country
}

Success function indicates the user data has been set.

Failure function returns an error String.

clearUserData(Function success, Function failure)

Success function indicates the user data has been cleared.

Failure function returns an error String.

Login

In your onDeviceReady event add the following

var fbLoginSuccess = function (userData) {
  console.log("UserInfo: ", userData);
}

facebookConnectPlugin.login(["public_profile"], fbLoginSuccess,
  function loginError (error) {
    console.error(error)
  }
);

Get Access Token

If you need the Facebook access token (for example, for validating the login on server side), do:

var fbLoginSuccess = function (userData) {
  console.log("UserInfo: ", userData);
  facebookConnectPlugin.getAccessToken(function(token) {
    console.log("Token: " + token);
  });
}

facebookConnectPlugin.login(["public_profile"], fbLoginSuccess,
  function (error) {
    console.error(error)
  }
);

Get Status and Post-to-wall

For a more instructive example change the above fbLoginSuccess to;

var fbLoginSuccess = function (userData) {
  console.log("UserInfo: ", userData);
  facebookConnectPlugin.getLoginStatus(false, function onLoginStatus (status) {
    console.log("current status: ", status);
    facebookConnectPlugin.showDialog({
      method: "share"
    }, function onShareSuccess () {
      console.log("Posted.");
    });
  });
};

Getting a User's Birthday

Using the graph api this is a very simple task:

facebookConnectPlugin.api("me/?fields=id,birthday&access_token=" + myAccessToken, ["user_birthday"],
  function onSuccess (result) {
    console.log("Result: ", result);
    /* logs:
      {
        "id": "000000123456789",
        "birthday": "01/01/1985"
      }
    */
  }, function onError (error) {
    console.error("Failed: ", error);
  }
);

Hybrid Mobile App Events

Starting from Facebook SDK v4.34 for both iOS and Android, there is a new way of converting pixel events into mobile app events. For more information: https://developers.facebook.com/docs/app-events/hybrid-app-events/

In order to enable this feature in your Cordova app, please set the FACEBOOK_HYBRID_APP_EVENTS variable to "true" (default is false):

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable FACEBOOK_HYBRID_APP_EVENTS="true"

Please check this repo for an example app using this feature.

GDPR Compliance

This plugin supports Facebook's GDPR Compliance Delaying Automatic Event Collection.

In order to enable this feature in your Cordova app, please set the FACEBOOK_AUTO_LOG_APP_EVENTS variable to "false" (default is true).

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable FACEBOOK_AUTO_LOG_APP_EVENTS="false"

Then, re-enable auto-logging after an end User provides consent by calling the setAutoLogAppEventsEnabled method and set it to true.

facebookConnectPlugin.setAutoLogAppEventsEnabled(true, function() {
  console.log('setAutoLogAppEventsEnabled success');
}, function() {
  console.error('setAutoLogAppEventsEnabled failure');
});

Collection of Advertiser IDs

To disable collection of advertiser-id, please set the FACEBOOK_ADVERTISER_ID_COLLECTION variable to "false" (default is true).

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable FACEBOOK_ADVERTISER_ID_COLLECTION="false"

Then, re-enable collection by calling the setAdvertiserIDCollectionEnabled method and set it to true.

facebookConnectPlugin.setAdvertiserIDCollectionEnabled(true, function() {
  console.log('setAdvertiserIDCollectionEnabled success');
}, function() {
  console.error('setAdvertiserIDCollectionEnabled failure');
});

Advertiser Tracking Enabled (iOS Only)

To enable advertiser tracking, call the setAdvertiserTrackingEnabled method.

facebookConnectPlugin.setAdvertiserTrackingEnabled(true, function() {
  console.log('setAdvertiserTrackingEnabled success');
}, function() {
  console.error('setAdvertiserTrackingEnabled failure');
});

See the Facebook Developer documentation for more details.

App Ads and Deep Links

getDeferredApplink(Function success, Function failure)

Success function returns the deep link if one is defined.

Failure function returns an error String.

Note that on iOS, you must use a plugin such as cordova-plugin-idfa to first request tracking permission from the user, then call the setAdvertiserTrackingEnabled method to enable advertiser tracking. Attempting to call getDeferredApplink without doing so will result in an empty string being returned.

cordova.plugins.idfa.requestPermission().then(function() {
  facebookConnectPlugin.setAdvertiserTrackingEnabled(true);
  facebookConnectPlugin.getDeferredApplink(function(url) {
    console.log('url = ' + url);
  });
});

See the Facebook Developer documentation for more details.

URL Suffixes for Multiple Apps

When using the same Facebook app with multiple iOS apps, use the FACEBOOK_URL_SCHEME_SUFFIX variable to set a unique URL Suffix for each app. This ensures that Facebook redirects back to the correct app after closing the login window.

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable FACEBOOK_URL_SCHEME_SUFFIX="mysecondapp"

cordova-plugin-facebook-connect's People

Contributors

antonfire avatar aogilvie avatar blaind avatar divyekhanna avatar dokterbob avatar dtritus avatar dudeofawesome avatar gabrielctroia avatar goya avatar grmmph avatar jcvalerio avatar jeduan avatar jkassis avatar jkervine avatar josemedaglia avatar keab42 avatar levsa avatar matiasleidemer avatar matiassingers avatar mixtmeta avatar mkorganashvili avatar ngumby avatar noahcooper avatar pamelafox avatar peterpeterparker avatar pragunvohra avatar robertarnesson avatar shazron avatar simllll avatar stevengill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-plugin-facebook-connect's Issues

AndroidX / Program type already present: android.support.customtabs.ICustomTabsCallback$Stub

Bug or feature request

[X] I'm reporting a reproducible issue with the code
[ ] I'm reporting a feature request

Describe the Bug of feature request

After installing the plugin, android build fails with the following error:

D8: Program type already present: android.support.customtabs.ICustomTabsCallback$Stub

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForRelease'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list:
  Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.customtabs.ICustomTabsCallback$Stub

Expected Behavior

Expected the build to finish.

Plugin version, OS, devices, etc
Plugin-Version: 2.2.0
ionic info:

Ionic:

   Ionic CLI                     : 6.12.2 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.5
   @angular-devkit/build-angular : 0.10.7
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.3.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : 6.0.0, android 8.1.0, browser, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 19 other plugins)

Utility:

   cordova-res (update available: 0.15.3) : 0.15.0
   native-run (update available: 1.3.0)   : 0.3.0

System:

   Android SDK Tools : 26.1.1 (/Users/XXX/Library/Android/sdk)
   ios-deploy        : 1.10.0
   ios-sim           : 8.0.2
   NodeJS            : v11.15.0 (/usr/local/bin/node)
   npm               : 6.14.5
   OS                : macOS Catalina
   Xcode             : Xcode 12.3 Build version 12C33

Additional Context

Checking the link in the error message, it says this should be resolved by removing one of the duplicated dependencies.
Using ./gradlew app:dependencies to list the deps-tree gives this output: https://pastebin.com/pk6W0VRp

Showing that com.android.support:customtabs is listed twice. This doesn't seem to be the problem though, because after removing cordova-plugin-facebook-connect the output is this: https://pastebin.com/5yauyCmg
Still listing com.android.support:customtabs twice, but not producing an error on build.

Only stripping out the diff between these two dep-trees are these:
https://pastebin.com/qWHWVNGG

Leading me to the idea that this might be caused by the AndroidX-dependencies?
Since we're an older version of ionic not yet migrated to AndroidX because of budget & some older plugins being used.

Important note

Appreciate the support for these possibly legacy issues and would still be willing to compensate for the time.

Thanks for the time.

Expiring Daemon because JVM heap space is exhausted

Please do not submit support requests or "How to" questions here. Instead, please use channels like StackOverflow, the Ionic forum or the Ionic slack channel

For issues or feature requests related to the code in this repository file a Github issue and provide as much details as possible

Bug or feature request

[x] I'm reporting a reproducible issue with the code
[ ] I'm reporting a feature request

Describe the Bug of feature request

Expiring Daemon because JVM heap space is exhausted
Daemon will be stopped at the end of the build after running out of JVM memory
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
<============-> 99% EXECUTING [11m 9s]

IDLE
IDLE
:app:mergeExtDexRelease
IDLE
IDLE
IDLE
IDLE
IDLE

Always fail when added this plugin.
Once remove this plugin, build will success.

Expected Behavior

Build successful

Sample repo

A sample repo is needed for this issue to be fixed, please provide one in order to reproduce the problem.

You could for example try to use the cordova-plugin-facebook-connect-lab to reproduce your issue.

Plugin version, OS, devices, etc

Android

Additional Context

List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, screenshots, OS if applicable, etc.

Important note

Unfortunately since this is a project done in spare time, support requests or "How to" questions will be closed without any further comments

If we consider your issue to not be well documented, it will be closed without further comments too

Thx you in advance for your understanding

Email is not retuned from facebookConnectPlugin.api

Bug or feature request

[X ] I'm reporting a reproducible issue with the code
[ ] I'm reporting a feature request

Describe the Bug of feature request

Old plugin returns email, new plugin does not.

Expected Behavior

Return email as the old one did

Sample repo

facebookConnectPlugin.api("me/?fields=id,name,email&access_token=" + success.authResponse.accessToken, ["public_profile", "email"],

Same exact code for old and new plugin. cordova-plugin-facebook4 (old returns email) and cordova-plugin-facebook-connect (latest does not return email)

Plugin version, OS, devices, etc

Ionic:

Ionic CLI : 6.12.1 (/Users/jasonandress/.nvm/versions/node/v12.6.0/lib/node_modules/@ionic/cli)
Ionic Framework : ionic1 1.3.4
@ionic/v1-toolkit : 2.0.20

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : ios 6.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 24 other plugins)

Utility:

cordova-res : 0.15.1
native-run : 1.2.2

System:

Android SDK Tools : 26.1.1 (/Users/jasonandress/Library/Android/sdk)
ios-deploy : 1.9.4
ios-sim : 8.0.2
NodeJS : v12.6.0 (/Users/jasonandress/.nvm/versions/node/v12.6.0/bin/node)
npm : 6.14.11
OS : macOS Big Sur
Xcode : Xcode 12.3 Build version 12C33

setUserData alternative for logEvents

Bug or feature request

  • I'm reporting a reproducible issue with the code
  • I'm reporting a feature request

Describe the Bug of feature request

setUserData capability for Advanced Matching

https://developers.facebook.com/docs/app-events/advanced-matching/

Expected Behavior

I would like to be able to set user properties for future logEvent requests or a way to pass fn, ln, email, phone parameters for Facebook Advanced Matching

Plugin version, OS, devices, etc

  • iOS
  • Android

Additional Context

I was not able to find in the documentation how to access setUsrData nor how to provide hashed user parameters on the requests. Any alternative would suffice my needs.

Support request

https://stackoverflow.com/questions/66716303/facebook-setuserdata-alternative-for-logevents

[android] facebookConnectPlugin.logout has no effect

Hello,

Calling facebookConnectPlugin.logout() seems to have no effect, even if success callback is triggered.
Logging-in again with facebookConnectPlugin.login() does not show Facebook login-form modal, and directly returns success.
Flushing app cache+data has no effect either.

Even trying to force disconnect right before login has no effect :

const next = () => {
	facebookConnectPlugin.login( ["public_profile", "email"], function( result ) {
		console.log( "success", result )
	}, function(error) {
		console.log( "fail", error )
	})
}
facebookConnectPlugin.logout( next, next )

What am I missing ?

cordova version : 10.0.0
cordova-android version : 9.0.0
cordova-plugin-facebook-connect version : 2.3.0

not opening the fb app, opening in embedded. browser only

I am trying to use this plugin in ios 13.6.1 iphone se
when i make the login call it always open in the embedded browser and not in the facebook app.

i have checked stackoverflow and other platform and made the changes suggested such as. enable single sign on and other

please if anyone else is facing the same problem then please drop a comment

also the android build is failing because of the Dex error ..

FR: Support GDPR Compliance

Bug or feature request

[ ] I'm reporting a reproducible issue with the code
[X] I'm reporting a feature request

Describe the Bug of feature request

As of the EU data protection law, we are not allowed to send FB Events before the user accepts this. As the Facebook SDK automatically sends Install and Open Events that is a Problem. I found this: https://developers.facebook.com/docs/app-events/gdpr-compliance/

Is it possible for you to implement this Delaying Automatic Event Collection Feature?

Expected Behavior

As far as i understand it works like this: By setting the Variable to delay the events these events are queued and only fired to facebook after Settings.isAutoLogAppEventsEnabled is set back to true via Code?

Android: File Input does not work when Facebook Connect Plugin is installed

Bug: File Input does not work on Android due to this plugin

[x] I'm reporting a reproducible issue with the code
[ ] I'm reporting a feature request

I am using the plugin with the latest version of Ionic (Angular) and Capacitor and have the following problem:

I am using a simple input to upload a file, like this:
<input type="file" accept="application/pdf, .pdf" (change)="onInputChange($event)" />

I created an empty Ionic project with Capacitor integration. In this case everything works fine. Clicking the input opens the native filepicker and selecting a file correctly displays the selected file in the input. The onInputChange method is correctly triggered.

This changes when installing the facebook-connect plugin. When first clicking the input, the native file picker is shown, but selecting a file does neither trigger the onInputChange method nor show the name of the selected file in the input. Clicking the input again does not even show the native filepicker anymore.

It seems to me like the plugin "swallows" the activity-change somehow (I am not an Android developer though).

Sample repo
I created a sample repository with the above mentioned starter project and installed the facebook-connect plugin (see "BREAKING COMMIT"). Please make sure to run npx cap sync to make sure that the native Android project correctly reflects the currently installed node modules.

Expected Behavior
The facebook-connect plugin should not interfere with the file input

Plugin version, OS, devices, etc
I am using the latest version of the plugin (2.3.0) with the latest version of Ionic (5.6.9) and Capacitor (v3.0.1).

Any help is greatly appreciated. Thank you very much!

Feature Request: Add support for the FB "setDataProcessingOptions" api

Bug or feature request

[ ] I'm reporting a reproducible issue with the code
[x] I'm reporting a feature request

Describe the Bug of feature request

Add support for the FB "setDataProcessingOptions" api so developers can comply with CCPA requirements.
https://developers.facebook.com/docs/app-events/guides/ccpa

Expected Behavior

Calls the new api would set the LDU flag with optional country, stat params

Sample repo

A sample repo is needed for this issue to be fixed, please provide one in order to reproduce the problem.

You could for example try to use the cordova-plugin-facebook-connect-lab to reproduce your issue.

Plugin version, OS, devices, etc

2.1

Additional Context

https://developers.facebook.com/docs/app-events/guides/ccpa

iOS: Activate App event is auto-logged anyway with used FACEBOOK_AUTO_LOG_APP_EVENTS="false"

Bug or feature request

[X] I'm reporting a reproducible issue with the code
[ ] I'm reporting a feature request

Describe the Bug of feature request
iOS Activate App events are auto-logged with the used FACEBOOK_AUTO_LOG_APP_EVENTS="false". (These events are shown in Facebook Events Manager during testing. Android app works correctly)

The plugin was added with the command below according to the docs

$ cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="***" --variable APP_NAME="***" --variable FACEBOOK_AUTO_LOG_APP_EVENTS="false"

Looks like [FBSDKAppEvents activateApp] method is called in [FacebookConnectPlugin applicationDidBecomeActive:] regardless the Facebook setting isAutoLogAppEventsEnabled.

Please compare applicationDidBecomeActive method in FacebookConnectPlugin.m and FBSDKApplicationDelegate.m from FBSDKCoreKit.

FacebookConnectPlugin.m

- (void) applicationDidBecomeActive:(NSNotification *) notification {
    [FBSDKAppEvents activateApp];
   ...
}

FBSDKApplicationDelegate.m from FBSDKCoreKit

- (void)applicationDidBecomeActive:(NSNotification *)notification
{
...
  // Auto log basic events in case autoLogAppEventsEnabled is set
  if (FBSDKSettings.isAutoLogAppEventsEnabled) {
    [FBSDKAppEvents activateApp];
  }
...
}

Expected Behavior

iOS Activate App events shouldn't be auto-logged with the used FACEBOOK_AUTO_LOG_APP_EVENTS="false" variable.

Plugin version, OS, devices, etc
cordova-plugin-facebook-connect 1.1.0
cordova version 10.0.0, cordova-ios 6.1.1, iOS 14.3

Facebook login fails when facebook app is installed

Hi
I'm facing this error when trying to login using facebook with android device:

facebook login error: there is an error in logging you into this application

I figured out this happens only when the facebook app is installed! It seems to be a common problem due to this issue.
I have installed this plugin recently (before I used to use cordova-plugin-facebook4 and this didn't happen).
any way, I'm not sure if this is a bug related to the facebook app or facebook-connect plugin but it will be a big help if you take a look.

Graph API upgrade

I got the following alert:

Your App, is currently accessing Graph API v3.2 which will reach the end of its 2-year lifetime on 04 May, 2021. We estimate 1 endpoint that Inztasac calls will be impacted by this change and may stop working after the automatic upgrade push. To ensure a smooth transition, please migrate all calls to Graph API v3.3 or higher. Use the API Upgrade Tool to understand exactly how this change will impact your app.

How can I change the used Graph API version ?

I saw in the readme file that this plugin will always be released for iOS and for Android with a synchronized usage of the Facebook SDKs and the Graph API is related to the released SDK.

Podfile not replacing $FACEBOOK_IOS_SDK_VERSION / installing failed

Describe the Bug of feature request

When trying to install this plugin via:
cordova plugin add cordova-plugin-facebook-connect --save --variable APP_ID="APP_ID" --variable APP_NAME="APP NAME"

the command always fails with the following error output:

Installing "cordova-plugin-facebook-connect" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-facebook-connect" for browser
6.0.0
Installing "cordova-plugin-facebook-connect" for ios
Running command: pod install --verbose
Failed to install 'cordova-plugin-facebook-connect': Error: pod: Command failed with exit code 1
    at ChildProcess.whenDone (/Users/...path-to-project.../node_modules/cordova-common/src/superspawn.js:135:23)
    at ChildProcess.emit (events.js:193:13)
    at maybeClose (internal/child_process.js:999:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
pod: Command failed with exit code 1

Since it seems to only fail on "installing for ios" I tried installing the pods manually and saw, that the Podfile looked like this:

target 'Project' do
	project 'Project.xcodeproj'
	pod 'OneSignal', '2.14.2'
	pod 'FirebaseMessaging', '~> 2.0.0'
	pod 'FBSDKCoreKit', '$FACEBOOK_IOS_SDK_VERSION'
	pod 'FBSDKLoginKit', '$FACEBOOK_IOS_SDK_VERSION'
	pod 'FBSDKShareKit', '$FACEBOOK_IOS_SDK_VERSION'
end

and when running pod install manually it obviously can't resolve the $FACEBOOK_IOS_SDK_VERSION variable.
I tried replacing them manually with 9.0.1. as provided in ios.json, which works for the pod install command, but leaves other build errors, since the plugin install probably hasn't finished correctly.

Expected Behavior

Expected the install command to run without errors.

Plugin version, OS, devices, etc

Newest plugin version 2.1.0.

Ionic:

   Ionic CLI                     : 6.12.2 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.5
   @angular-devkit/build-angular : 0.10.7
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.3.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : 6.0.0, android 8.1.0, browser, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 19 other plugins)

Utility:

   cordova-res (update available: 0.15.3) : 0.15.0
   native-run (update available: 1.3.0)   : 0.3.0

System:

   Android SDK Tools : 26.1.1 (/Users/reesz/Library/Android/sdk)
   ios-deploy        : 1.10.0
   ios-sim           : 8.0.2
   NodeJS            : v11.15.0 (/usr/local/bin/node)
   npm               : 6.14.5
   OS                : macOS Catalina
   Xcode             : Xcode 12.3 Build version 12C33

Additional Context

Already tried following the trouble shooting for iOS here: https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect/blob/master/docs/ios/README.md
and updated pods, pods repo and cocoa pods.

Is there anything I am missing here? I'll leave anyone a coffee who can point me towards the solution.

Thanks for your time! ๐Ÿ™

14.5 > IDFA requires to ask for user Permission

[ ] I'm reporting a reproducible issue with the code
[x] I'm reporting a feature request

Describe the Bug of feature request

Need to add the ask permission for use track data

Expected Behavior

Use the ATTrackingManager to request user permission to use his data

Plugin version, OS, devices, etc

IOS 14.5 >

Additional Context

For the 14.5 > the IDFA requests that you request user permission to use his data or track him
Utilizing the:

//ask for user permission
- (bool) requestUserPermissionForIDFA() { 
  if (@available(iOS 14, *)) {
    [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
      if(status == ATTrackingManagerAuthorizationStatusAuthorized) {
        return YES;
      } 
        return NO;
      }
  }
}

auth/account-exists-with-different-credential

I'm facing a firebase error auth/account-exists-with-different-credential when I'm trying to sign in an already existing account(with different auth provider) with facebook. I know this question has been asked many times like here and here but all solutions works for web and I'm stuck with native plugins. I'm using Google Plus and Facebook Connect plugins to sign in on native platforms.

Code:

async continueWithGoogle() {
    try {
      const googleResponse = await this.googlePlus.login({ webClientId: environment.firebaseConfig.webClientId })
      const googleCredential = firebase.default.auth.GoogleAuthProvider.credential(googleResponse.idToken);
      const firebaseResponse = await firebase.default.auth().signInWithCredential(googleCredential);
      return firebaseResponse;
    } catch (error) {
        console.log('continue with google: ', error);
    }
  }

async continueWithFacebook() {
    try {
      const fbResponse = await this.facebook.login(['email']);
      const fbCredential = firebase.default.auth.FacebookAuthProvider.credential(fbResponse.authResponse.accessToken);
      const firebaseResponse = await firebase.default.auth().signInWithCredential(fbCredential);
      return firebaseResponse;
    } catch (error) {
      if (error.code === 'auth/account-exists-with-different-credential') {
        
        // What should I do here?

      }
      console.log('continue with fb: ', error);
    }
  }

Can I solve this error without using any web method like signInWithRedirect() or signInWithPopup()?

Update facebook sdk pods got error on build

[x] I'm reporting a reproducible issue with the code
[x] I'm reporting a feature request

Describe the Bug of feature request

Hello, I want to update the facebook sdk, so I edit manually the pods file at platform/ios like:

pod 'FBSDKCoreKit', '8.0.0'
pod 'FBSDKLoginKit', '8.0.0'
pod 'FBSDKShareKit', '8.0.0'

The problem is that then when I build for "ios" I got an error on the FacebookConnectPlugin.m file at /Users//../platforms/ios/Seaver/Plugins/cordova-plugin-facebook4/FacebookConnectPlugin.m

I attached a picture with the missing stuff and alerts on the file.

Expected Behavior

Should build without problems, but I suspect that we need to update the code of the ios part of the plugin in order to adjust to the last facebook sdk, without this new sdk I think all facebook features will not work on ios 14.

I'm not super experienced in objective-c but if you give me some advice I can make the changes and do the pr

Plugin version, OS, devices, etc

I used last version of the plugin and:
ionic v3
cordova 9.0.0
cordova-ios 6.0.0

Captura de pantalla 2021-03-16 a las 16 38 01

Method setAdvertiserIDCollectionEnabled missing

Hey guys you have added the new events for ads in the readme, code everywhere.

Issue happens on v1.2.0

But forgot to add

    exports.setAdvertiserIDCollectionEnabled = function (enabled, s, f) {
        exec(s, f, 'FacebookConnectPlugin', 'setAdvertiserIDCollectionEnabled', [enabled]);
    }

In the facebook-native.js file
Causing this function to be inexistent at all.

- (BOOL)swizzled_application methods calling themselves recursively can crash the app

Bug or feature request

[ x] I'm reporting a reproducible issue with the code
[ ] I'm reporting a feature request

Describe the Bug of feature request

Is there any reasonable explanation why both methods listed bellow are calling themselves recursively? Am I missing something? I mean, just by looking at the code it feels wrong.
I had the wrong behaviour with the original plugin and it still persists on this fork.
Whenever one of these methods are called they simply crash the app because they call themselves over and over again

- (BOOL)swizzled_application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
....
return [self swizzled_application:application openURL:url options:options];
- (BOOL)swizzled_application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
....
return [self swizzled_application:application openURL:url sourceApplication:sourceApplication annotation:annotation];

Expected Behavior

we should add a return YES at the end of statement and remove the recursive call

Sample repo

A sample repo is needed for this issue to be fixed, please provide one in order to reproduce the problem.

You could for example try to use the cordova-plugin-facebook-connect-lab to reproduce your issue.

Plugin version, OS, devices, etc

Latest plugin version, IOS

Additional Context

It happens when the app is opened using an url scheme (deeplink or similar)

Important note

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.