I was able to get the facebookConnectPlugin working on iOS using PhoneGap and Ionic. The issue is that when I try to run the exact same app on Android I get the error "facebookConnectPlugin is not defined". I'm using PhoneGap Build and am not building natively for Android.
Here are the steps I've taken to try to get it working on Android:
1) Generated a new keystore.
"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000
2) Created a new hash using this keystore.
"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
Used the password "android" everywhere it asked me for a password (for the keystore and the hash).
3) Added the following to my config.xml document:
<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0">
<param name="APP_ID" value="XXXXXXXXXX" />
<param name="APP_NAME" value="MyApp" />
</gap:plugin>
The APP_ID I got from Facebook and the APP_NAME was the display name from Facebook.
4) Created an Android key in PhoneGap build uploading the keystore I specified and the alias "androiddebugkey". For all the passwords, including the certificate password I input my password "android".
5) Uploaded my application to PhoneGap build, installed it on an Android emulator (Lollipop using Visual Studio Emulator for Android) and tried to log into Facebook using the following code. This code fires after $ionicPlatform.ready.
var _this = this;
var fbLoginSuccess = function (userData) {
facebookConnectPlugin.api("me/?fields=id,email", ["public_profile"],
function (result) {
},
function (error) {
alert("Failed: " + error);
}
);
}
facebookConnectPlugin.login(["public_profile"],
fbLoginSuccess,
function (error) {
alert(JSON.stringify(error));
}
);
6) For my site at developers.facebook.com I added an Android app. The Google Play Package Name is the same as my "id" in the widget element in config.xml. For the Class Name, I specified the exact same thing as the id, but with ".MainActivity" appended to it. I inserted the Key Hash generated from Step 2 above into the Key Hashes field. I turned Single Sign On on. Not sure if that is correct or not.
I've spent days trying to figure this out with no luck. I'm not sure if the issue is with the hash, cordova, or some other Facebook permissions. Like I said earlier, it works fine on iOS. It's just Android that has the problem.
Any help would be very much appreciated.
#oalbrecht,
I am posting this link with the hope you will read the entire document.
Top Mistakes by Developers new to Cordova/Phonegap
In fact your error was
3. Does not follow the blogs.
For you see, we have now move to a new repository on npm.org. This actually gets you another error
11. You need to get your plugins from NPM now.
How did I figure this out? I did a google search of your plugin: com.phonegap.plugins.facebookconnect
About three (3) links down is your plugin: FacebookConnect
The documentation says
REPOSITORY IS NOW DEPRECATED!!!
Please go here
READ THE DIRECTIONS CAREFULLY. This is an ugly plugin. The correct links are:
github
npm
Your new plugin setting is:
<gap:plugin name="cordova-plugin-facebookconnect-orlando" source="npm" version="0.11.0">
Related
I have a React-Native app and I am using the firebase SDK for React-Native. I have just implemented App-Check for my app and it works fine in debugging mode, but it fails in Release. Here is the code for app-check in index.js which is triggered as soon as app is initialized:
try {
firebase.appCheck().setTokenAutoRefreshEnabled(true);
firebase.appCheck().activate('ignored', true);
firebase.appCheck().getToken(true).then(res => {
GLOBAL.app_check = JSON.stringify(res.token);
console.log("app check success, appchecktoken: " + JSON.stringify(res.token));
}).catch((error) => {
GLOBAL.app_check = '';
console.error("app check failed: " + error);
alert('App check failed: ' + JSON.stringify(error));
return;
});
} catch (e) {
console.log("Failed to initialize appCheck:", e);
logErrors('appCheck failed: ', e);
}
as you can see above, I am using alert to print the error message but here it what it prints:
**App check failed: {} **
.. object is empty. How can I check what's wrong with it? I am using Play Integrity and SafetyNet and I have added the SHA-252 which I got by using Gradle's Signing Report via the following command:
gradlew signingReport
What am I doing wrong here?
You will need to get the SHA-256 for all signing keys used with your app. With debug keys, calling gradlew signingReport works as it goes to the default signing key location (~/.android/debug.keystore) and runs the java keytool against this keystore supplying the default alias (android) and password (android).
For your release keys, which are self generated, you would need to use the java keytool which can generally be found on your system path or within the jdk directory. If you need help setting up keytool, I would refer to this stackoverflow question. You could use any other variations of keytool that exist, but I would use the one that ships with the jdk as its generally trusted. The command you would then want to run using keytool would be:
keytool -list -v -alias ${alias_of_keystore} -keystore ${location_of_keystore}
You would want to sub the alias and location with your own values. Using the default debug key values, the command would look something like this:
keytool -list -v -alias android -keystore ~/.android/debug.keystore
This video talks about all the different locations to grab the SHA-256. For instance, after you upload to the Google Play Store, if you opt into Google Play Signing (which I believe is the default) you will need to grab the SHA-256 from there as well. The rest of the video covers digital asset links and can be ignored.
In the README of MSAL, a configuration file is discussed, containing what is referred to by "YOUR_BASE64_URL_ENCODED_PACKAGE_SIGNATURE".
They also advise the user to store this as a "raw" resource.
This is the template given:
{
"client_id" : "<YOUR_CLIENT_ID>",
"redirect_uri" : "msauth://<YOUR_PACKAGE_NAME>/<YOUR_BASE64_URL_ENCODED_PACKAGE_SIGNATURE>",
"broker_redirect_uri_registered": true,
}
Won't the contents of this file affect the signature? How is it possible to have a static asset containing the signature?
I'm led to believe that this is not, as I thought, a cryptographic signature of the APK.
I couldn't figure out what it is.
I think it makes sense, it shouldn't be static. You want Microsoft to be able to prove that it is authenticating against your real app and not a modified or different application. This is the signed application for release with apk.
You need to sign your app in order to be able to put it on the play store or to have it validate: https://developer.android.com/studio/publish/app-signing
Per the Microsoft documentation:
https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-android#integrate-with-microsoft-authentication-library
it tells you how to generate the hash. in the portal when you set up the authentication on app reg it will give you a command like
keytool -exportcert -alias SIGNATURE_ALIAS -keystore PATH_TO_KEYSTORE | openssl sha1 -binary | openssl base64 to generate the signature it just gets gets the signature of the android keystore keys.
We are using react-native-google-signIn for android in our project. We have created a project in google developer console and downloaded the google-services.json file. The google-services.json file is placed in android/apps folder.
When we configure the googleSignIn in code , am getting error: 10 code from google.
GoogleSignin.configure({
webClientId:'***********************.apps.googleusercontent.com'
})
If i don't pass the webClientId , the sign-in is successful but idToken is returned as null in the user object.
I made sure that the webClientId value is correct by following [1] and [2].
Any suggestions in this regard will be appreciated.
Your SHA-1 key may be incorrect. The comment of #mtt87 did help me:
https://github.com/devfd/react-native-google-signin/issues/224
I am using firebase and kept getting the same issue until I passed the web client_id from the firebase google-services file into the GoogleSignin.configure method.
await GoogleSignin.configure({
webClientId: '<unique string>.apps.googleusercontent.com',
});
const userInfo = await GoogleSignin.signIn();
May be there is a problem related to SHA1 key.
Make sure you have placed both debug and release SHA1 key to your firebase project.
for finding SHA1 key:
go to your android folder and hit below command
For debug mode :
keytool -keystore app/debug.keystore -list -v
For release mode:
keytool -keystore app/release.keystore -list -v
I'm using native Google Plus plugin with Ionic 3 app.
Login() method is like this:
login(){
GooglePlus.login({
'webClientId': '*************************'
}).then((res) => {
console.log(res);
}, (err) => {
console.log(err);
});
}
The problem here is about the webClientId.Hence I have created 2 apps on developer console (iOS and Android), it shows 2 different webClientIds.So which value should I give to above code?
Helpful link: Ionic Google Authentication
Plugin link: enter link description here
You don't need to put webClientId in GooglePlus.login().
Your login method should be (if no additional options)-
GooglePlus.login({}).then((res) => {
console.log(res);
}, (err) => {
console.log(err);
});
iOS
You need to put REVERSED_CLIENT_ID in config.xml for iOS.
<plugin name="cordova-plugin-googleplus" spec="~5.1.1">
<variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.967272422526-vu37jlptokv45glo2kciu9o2rddm7gte" />
</plugin>
To find you REVERSED_CLIENT_ID, in developer console go to credentials and click on created iOS credential and Download Plist.
Android
For android you don't need any id, it works on Signing-certificate fingerprint, make sure the Signing-certificate fingerprint and Package name are correct while creating oauth client id.
If you are not signing your apk with any created keystore file then take SHA-1 signing-certificate fingerprint of default debug.keystore file.
keytool -exportcert -keystore C:\Users\Username\.android\debug.keystore -list -v
I have used most common path of debug.keystore (windows). It might be different for you, just look for .android dir.
Find your REVERSED_CLIENT_ID inside GoogleService-Info.plist from firebase.
Good morning
I'm trying to build an Android application on release mode using Visual Studio Tools for Apache Cordova CTP3.1
After I create my myreleasekey.keystore using android tools
http://developer.android.com/tools/publishing/app-signing.html
I set data in ant.properties
key.store=C:\\Users\\myreleasekey.keystore
key.alias=MoayadMyro
key.store.password=password
key.alias.password=password
I got error :
Error : BLD00213 : Signing key MoayadMyro not found. Verify the alias in ant.properties is correct.
cmd: Command failed with exit code 8
Thanks
I had exactly the same problem and no matter the permutations of keystore alias I tried, I kept getting the same error in visual studio for Apache Cordova.
To resolve I simply repeated the generation process.
Generate a new key store using keytool:
C:\myChosenDir> keytool -genkey -keyalg RSA -alias selfsigned -keystore mykeystorename.keystore -storepass mykeystorepass -validity 10000 -keysize 2048
Enter the information requested as part of the keygen:
When requested to enter the password for <selfsigned> reenter the password above. Hitting return suggests it uses the same but this is what I did before and it didn't work. [This was the only thing I did different]
Add the keystore to the project:
I placed the keystore in the same folder as the ant.properties file
Update the ant properties file:
key.store=mykeystorename.keystore
key.alias=selfsigned
key.store.password=mykeystorepass
key.alias.password=mykeystorepass
[NB: preserve the line breaks can't get them to play correctly in markdown]
I know this a bit of a turn it off and turn it on again answer but it worked for me. Best of luck.