phonegap 3.0 facebook login - facebook

I m using phonegap 3.0 and trying to install the below faceook login plugin:
https://github.com/phonegap/phonegap-facebook-plugin
I have added the following changes in the config.xml file
<gap:plugin name="com.phonegap.plugins.facebookconnect">
<param name="APP_ID" value="[APP_ID]" />
<param name="APP_NAME" value="[APP_NAME]" />
But still when i am trying to install the plugin its giving me the following error:
Error: Variable(s) missing: APP_ID, APP_NAME
Can anyone tell me why this error might be occuring.M i missing adding any changes in some file.
Thanks

It looks like this plugin hasn't been rewritten for phonegap 3.x yet. Here is the issue on the github project where people are discussing it: https://github.com/phonegap/phonegap-facebook-plugin/issues/343
And here is where someone fixed the android part of the code to work with phonegap 3.x: https://github.com/phonegap/phonegap-facebook-plugin/pull/348
Also, here is where someone else was having trouble using it for iOS with phonegap 3.x: Phonegap 3.0.0 - Facebook SDK 3.6 - FB plugin: Facebook connect not found
On the instructions in the plugin readme it says:
6) Replace your appId in the new index.html file. Leave the quotes.
You can look in the examples folder and you'll see something like this:
document.addEventListener('deviceready', function() {
try {
alert('Device is ready! Make sure you set your app_id below this alert.');
FB.init({ appId: "appid", nativeInterface: CDV.FB, useCachedDialogs: false });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
Hope this helps

Plugin should be fully CLI compatible now on master branch.
Here is some sample code
cordova create myApp
cd myApp/
cordova platform add ios
cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
Enjoy.

I met this problem too. Here answer https://github.com/phonegap-build/FacebookConnect/issues/21

Related

Why is my Facebook and Ionic Capacitor integration having problems?

We are attemptin to integrate the facebook SDK for analytics into an Ionic/Capacitor app. Obviously, when following the install instructions here`, it is not possible to run the command
ionic cordova plugin add cordova-plugin-facebook-connect --variable APP_ID="123456789" --variable APP_NAME="myApplication"
We have tried installing using NPM, however when running it seems unable to locate the App ID and the App Name on Android, returning these errors:
AAPT: error: resource string/fb_app_id (aka capacitor.android.plugins:string/fb_app_id) not found.
I have tried using the Facebook Capacitor Analyzer plugin found here but that just caused more issues.
Surely someone out there has achieved this integration? Am I missing something? I have declared the App_ID and name in a strings.xml file - but it looks within a seperate AndroidManifest.xml file located inside the capacitor-cordova-android-plugins folder, which is generated when built.
Please help, any advice would be amazing
Is your app Capacitor or Cordova?
Because in capacitor apps, Cordova hooks don't work & you have to manually edit the Native Project Files or set the capacitor config file instead.
i.e. setting these variables in the console does not work.
--variable APP_ID="123456789"
--variable APP_NAME="myApplication"
please also check out the related SO post.
You can, however, use the capacitor configuration file & set the preferences here. example capacitor config:
{
appId: "com.myapp.app",
appName: "myApplication",
cordova: {
preferences: {
APP_ID: "123456789",
APP_NAME: "myApplication"
}
}

Ionic AppRate fails, incomplete object?

I am trying to add AppRate to my app based on the
https://ionicframework.com/docs/v3/native/app-rate/
example
TypeError: AppRate.preferences.openUrl is not a function. (In
'AppRate.preferences.openUrl(iOSStoreUrl)', 'AppRate.preferences.openUrl' is undefined)
That method is indeed missing on the object when inspected in debugger.
On the plugin documentation they add the method manually.
https://github.com/pushandplay/cordova-plugin-apprate
This approach fails for me however, too. My ionic app has no window object.
I had the same issue, but in ionic 4.
I solved it, firstly, reinstall the plugin from git repository or cordova plugins registry (to make sure we have the function openUrl added) and adding the missing method to #ionic-native/app-rate/ngx/index.d.ts like :
export interface AppRatePreferences {
...
...
...
openUrl?:(url:string) => void;
}
And after where you have used the call of the plugin, you add openUrl: appRate.preferences.openUrl to preferences properties like :
appRate.preferences = {
displayAppName: '',
storeAppURL: {
ios: '<my_app_id>',
android: 'market://details?id=<package_name>',
windows: 'ms-windows-store://pdp/?ProductId=<the apps Store ID>',
blackberry: 'appworld://content/[App Id]/'
},
openUrl: appRate.preferences.openUrl
};
Hope it helps you.
For ionic 3, Make sure the latest versions are installed with support for #ionic-native/app-rate#4
In my case I have solved it by installing version 4 of #ionic-native and version 1.4.0 of apprate.
Try this:
$ ionic cordova plugin rm cordova-plugin-apprate
$ ionic cordova plugin add cordova-plugin-apprate#1.4.0 --save --exact
$ npm install --save #ionic-native/app-rate#4

ionic3 plugin and platform errors

I am using ionic CLI version 3.0.0-beta.5
When I am trying to install native plugins, I am getting these errors.
for example, installing social-sharing plugin
ionic plugin add cordova-plugin-x-socialsharing
and the error is
[ERROR] Unknown plugin: #ionic/cli-plugin-.
same error while adding platforms also..
C:\Users\varun\Desktop\apps\app>ionic platform add android
The platform command is no longer available. To find out more about the equivalent please run:
ionic cordova:platform --help
C:\Users\varun\Desktop\apps\app>ionic cordova:platform --help
[ERROR] Unable to find command: cordova:platform. It is possible that you are trying to get help on a project based command and you are not in a project directory.
Has anyone faced this problem? I am not getting enough information on official blog.
To fix "The platform command is no longer available" issue on Ionic3 beta 7 I tried the following:
ionic cordova:platform add android
However, it only worked for newly started projects so need to update ionic-scripts in your project.
Use this instead
cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
The repo name cordova-plugin-x-socialsharing is changed/missing
so, we can directly add plugin from plugin git repo.
shareWithOptions(option, successcallback, errorcallback);
Usage :
window.plugins.socialsharing.shareWithOptions( {
message: 'share this',
subject: 'the subject',
files: ['', ''],
url: 'https://www.gooogle.com',
chooserTitle: 'Pick an app'
},
function(success){
console.log(success);
},
function(err){
console.log(err);});

Ionic 2 + Facebook (Cannot find 'facebookConnectPlugin')

I am creating an application using Ionic 2 that will make some calls to Facebook API. I followed the steps from documentation and installed the cordova plugin cordova-plugin-facebook4.
Now I'm trying to authenticate the user, but without success. My login page:
import {Page} from 'ionic-framework/ionic';
#Page({
templateUrl: 'build/pages/page1/page1.html',
})
export class Page1 {
login() {
facebookConnectPlugin.login(
['email'],
response => {
console.log(response);
},
error => {
console.log(error);
}
);
}
}
When I run the application with:
ionic serve
I get the following error in the terminal:
When I click on the login button I get the following error in the console:
And when I try to build the application to run on a real device I get the following error in the console:
I think I have to import the plugin to be able to use, but how?
try this.
install ionic-native npm install ionic-native --save
after this , you will need to import facebook import {Facebook} from 'ionic-native'
you can now use your facebook plugin this way
fblogin(){
this.platform.ready().then(() => {
Facebook.login(["email"]).then((result) => {
console.log(result)
})
})
}
make sure to put each permissions into separate string in the array
facebookConnectPlugin Cordova plugin does not work on browser, but if you try to run it on an emulator, it works fine. As per the instructions on jeduan's repo, you can get this to work on web apps, but I haven't tried it because it wasn't a necessity for me.
You can ignore Cannot find name facebookConnectPlugin error because it's just TypeScript complaining. It should work just fine after Transpiling to JS.
Not sure why you are getting build errors. Documentation has one major omission which could be the reason (Refer this issue). You need to pass your Facebook App ID and App Name (you can get it from developer.facebook.com)
ionic plugin add cordova-plugin-facebook4 --variable APP_ID="123456789" --variable APP_NAME="myApplication"
For Android, you also need to generate a key hash and provide it to Facebook. If you are on OSX, you can generate a keyhash like this:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
Friends,
I have done this and got it working. You need to register your app with the facebook developer portal and then add the cordova plugin and then write code. It's a lengthy process.
Detailed instructions given here - http://tphangout.com/?p=204
Hope this helps you, Thanks.

window.open() not working in phonegap build using new cordova and crosswalk plugin?

I´m experimenting with the new support for crosswalk webview using Phonegap Build
but run into some problem using window.open()
Info about the new cordova and crosswalk support
http://phonegap.com/blog/2015/06/16/phonegap-updated-on-build/
My config.xml
<preference name='phonegap-version' value='cli-5.1.1' />
<gap:plugin name='org.crosswalk.engine' version='1.3.0' source='pgb' />
<access origin="*" />
I am trying these javascript calls:
var ref = window.open('http://apache.org'); //Loads in the webview
var ref = window.open('http://apache.org', '_blank'); //Loads in the InAppBrowser
Javascript "syntax" from here:
https://wiki.apache.org/cordova/InAppBrowser
Result:
Nothing happens at all..
(It works great when I´m building my project without the new cordova and crosswalk).
When building in Phonegap build with the new cordova/crosswalk:
PhoneGap (iOS / Android / Windows)
cli-5.1.1 (3.8.0 / 4.0.2 / 3.8.1)
When building without:
PhoneGap (iOS / Android / Windows)
3.7.0 / 3.7.0 / 3.7.0
(My test device is an Samsung Galaxy Tab 3 running 4.4.4)
#Mikael,
it appears to be true that people only read what they want to read.
I asked, do you have:
a white-list
the white-list plugin
You said, "yes, I have a white-list". Where is your plugin? Did you read that part?
This is an "official" forum post, not blog, but forum post. Please read.
Notes for upgrading to cli-5.1.1 on PGB
http://community.phonegap.com/nitobi/topics/notes-for-upgrading-to-cli-5-1-1-on-pgb
Best of Luck,
Jesse