Last active
April 29, 2021 07:42
-
-
Save DaChelimo/9146145917c661a551c98696f9a88f45 to your computer and use it in GitHub Desktop.
Setting up API Keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<application> | |
... | |
<meta-data | |
android:name="com.facebook.sdk.ApplicationId" | |
android:value="${facebook_app_id}" /> | |
<activity | |
android:name="com.facebook.FacebookActivity" | |
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" | |
android:label="@string/app_name" /> | |
<activity | |
android:name="com.facebook.CustomTabActivity" | |
android:exported="true"> | |
<intent-filter> | |
<action android:name="android.intent.action.VIEW" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.BROWSABLE" /> | |
<data android:scheme="${fb_login_protocol_scheme}" /> | |
</intent-filter> | |
</activity> | |
</application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultConfig { | |
applicationId "com.andre_max.app_name" | |
minSdkVersion 17 | |
targetSdkVersion 30 | |
versionCode 1 | |
versionName "0.1.0" | |
vectorDrawables.useSupportLibrary = true | |
multiDexEnabled true | |
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |
// Set the properties within `gradle.properties` into a `Properties` class so that values | |
// within `gradle.properties` (e.g. Facebook API key) are accessible in this file. | |
Properties properties = new Properties() | |
if (rootProject.file("gradle.properties").exists()) { | |
properties.load(rootProject.file("gradle.properties").newDataInputStream()) | |
} | |
// Set Twitter keys to Build Config | |
buildConfigField('String', 'TWITTER_CONSUMER_KEY', properties.getProperty(twitter_consumer_key, "")) | |
buildConfigField('String', 'TWITTER_CONSUMER_SECRET', properties.getProperty(twitter_consumer_secret, "")) | |
// Inject the Facebook API key and login protocol scheme into the manifest | |
manifestPlaceholders = [ | |
facebook_app_id : properties.getProperty("facebook_app_id", ""), | |
fb_login_protocol_scheme: properties.getProperty("fb_login_protocol_scheme", "") | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#<!-- Facebook consumer key and secret --> | |
facebook_app_id"="" | |
fb_login_protocol_scheme="" | |
#<!-- Twitter consumer key and secret --> | |
twitter_consumer_key="" | |
twitter_consumer_secret="" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment