React Native and Facebook SDK on Android - react-native

I can't seem to get React Native FBSDK work on Android. I completed all the steps from registering the app to configuring the manifest file (can be found on this page: https://developers.facebook.com/docs/react-native/configure-android-current)
When I run the app I get the error: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first. I am using the latest version of react-native-fbsdk so the method above is deprecated. Also if I put the call into the main application class, the app crashes on startup.
So I'm kind of stuck here. Everything runs smooth on iOS but Android gives me headaches.

As you haven't shown code it's hard to know, but make sure you have:
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
// If you want to use AppEventsLogger to log events:
AppEventsLogger.activateApp(this);
SoLoader.init(this, /* native exopackage */ false);
}
in your MainApplication class (MainApplication.java)--at least, I didn't see that mentioned in the link you provided. Good luck

I have the same issue and I realize that I have to complete all steps to configure the native facebook sdk for android. Its mean you need to have a facebook account for this work.
What you need to do next is:
In your project open yourapp/android/build.gradle
Add the Maven Central Repository to build.gradle before dependencies:
repositories {
mavenCentral()
}
Add compile 'com.facebook.android:facebook-android-sdk:[4,5)'to your build.gradle dependencies
Build project
Open your strings.xml file, for example: /app/src/main/res/values/strings.xml.and add <string name="facebook_app_id">xxxxxxxxx</string>
Open your AndroidManifest.xml and add <uses-permission android:name="android.permission.INTERNET"/>
Add meta to application element <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
Generate a development key hash
You can see detail in quick start of developer facebook page (developers.facebook.com/quickstarts)

Related

Expo Apple Pay Stripe Merchant Identifier Issue

I am trying to implement Apple Pay on my Expo managed app.
I followed the documentation here https://stripe.com/docs/apple-pay except adding the capability in XCode (because it's an Expo app and it doesn't use Expo).
I have included my merchant ID in the plugins folder in my app.json.
And I have also wrapped my whole app in the <StripeProvider /> and included the merchantIdentifier there.
<StripeProvider merchantIdentifier="merchant.xxx.xxx.xxx" >
<App />
</StripeProvider>
enter code here
I believe that I've followed the documentation laid out by Expo and Stripe.
If I run expo config --type introspect I can see the entitlement there:
ios: {
entitlements: {
'aps-environment': 'development',
'com.apple.developer.in-app-payments': [
'merchant.com.xxx.xxx'
]
},
I then run eas build -p ios and create an ipa file. I then upload that to TestFlight to give the functionality a test on a real device.
But as soon as I try to call presentApplePay(), I get the error You must provide merchantIdentifier.
What am I missing here? Any help would be greatly appreciated.
You must include the publishableKey as well.

How to whitelist a vendor-specific API in AOSP for Android 10

I'm trying to add a vendor-specific API to my AOSP code base. I was able to get this working on Android 5 through 9, but cannot figure this out on Android 10.
I read the documentation on the AOSP docs for Implementing Java SDK Library
I have the following blueprint file:
java_sdk_library {
name: "com.mycompany.sdk.myclass",
srcs: ["java/**/*.java"],
api_packages: ["com.mycompany.sdk.myclass"],
}
I generated the api subdirectory using:
build/soong/scripts/gen-java-current-api-files.sh "vendor/mycompany/sdk/myclass" && m update-api
This put all my public method signatures into the current.txt file.
I added this as a boot jar to my top level board.mk file with:
PRODUCT_BOOT_JARS += com.mycompany.sdk.myclass
Building this creates the corresponding com.mycompany.sdk.myclass.xml permissions file:
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<library name="com.mycompany.sdk.myclass"
file="/system/framework/com.mycompany.sdk.myclass.jar"/>
</permissions>
Everything builds and installs fine. I verified the permissions file is in /system/etc/permissions/ and points to the correct jar filename. But I get "Accessing hidden method (blacklist, linking, denied)" exceptions when I run a test app built against my private SDK:
W/test_app: Accessing hidden method Lcom/mycompany/sdk/myclass;->myMethod(Landroid/content/Context;Z)V (blacklist, linking, denied)
I can eliminate this blacklist error by issuing the command:
adb shell settings put global hidden_api_policy 1
So I know my jar is being built and installed correctly. But is just blacklisted for 3rd parties.
I eventually added my package name to frameworks/base/config/hiddenapi-greylist-packages.txt, and suddenly my test app runs, and properly finds the private API. Unfortunately, the blacklist errors are replaced by greylist warnings on every method call. I don't want the log cluttered with these warnings, so it must be whitelisted, not greylisted.
I tried adding it to /build/make/core/tasks/check_boot_jars/package_whitelist.txt, but this made no difference.
How do I whitelist my private API instead of greylist?
There is no white list.
The white list (allow list) is the methods listed in Android SDK.
Private API are not in Android SDK.

Paytabs payment integration using dart, flutter web and api

I have a flutter web project and I was trying to implement a payment solution. I found out that paytabs is a good choice for my situation. I wanted to add their api but I kept getting the CORS erorr over my flutter website. So I tried their ready payment page but I am also unable to implement since I have no previous knowledge about web development. I only use dart and flutter. But I would like to implement the api since it gives higher control. This is the url used for post requests https://www.paytabs.com/apiv2/create_pay_page Using the http package I always have the CORS appearing as an error. Documentation for the paytab service: https://dev.paytabs.com/docs/paypage/ Hope you can help
There are not payment plugins available for flutter.
but we can integrate PayTabs by using flutter platform channel.
step 1-> Create the Flutter platform client final Map result = await methodChannel.invokeMethod('getPayTabs');
Exemple :`
Future<void> _getPayTabs() async {
String batteryLevel;
try {
debugPrint("this is dart getPayTabs");
final Map result = await methodChannel.invokeMethod('getPayTabs');
debugPrint("trasiction data $result");
} on PlatformException {
debugPrint("trasiction data Failed");
}
step 2-> Importing the SDK android project
In Android Studio, Right click on the app choose New > Module
Choose the Downloaded paytabs_sdk-v4.0.1.aar. If not, download here
Right click on your App and choose Open Module Settings
Add the Module dependency
Choose the: paytabs_sdk-v4.0.1 module to be included
Confirm the Module import by changing the Android view to Project view in the sidebar
Add below dependencies.
You can start with code changes.
You have to include the following dependencies:
allprojects {
repositories {
...
maven {
url 'https://jitpack.io'
}
}
}
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.github.dbachelder:CreditCardEntry:1.4.9'
step 3-> Add an Android platform-specific implementation
Start by opening the Android host portion of your Flutter app in Android Studio:
Open the file MainActivity.kt located in the kotlin folder in the Project view. (Note: If editing with Android Studio 2.3, note that the kotlin folder is shown as if named java.)
Inside the configureFlutterEngine() method, create a MethodChannel and call setMethodCallHandler(). Make sure to use the same channel name as was used on the Flutter client side.
You need to override your Activity’s onActivityResult

React native Fabric autolink error with react 60.0 and above

I have upgraded to my app to react-native 60.4 which support Autolinking all packages so that you dont have to manually go about setting things up and thus lowers the chances of error.
The problem is most of the packages have still not gotten compatible with this process and henceforth the app completely breaks.
my error is with https://github.com/corymsmith/react-native-fabric
referring to an issue on the repo for the same -> https://github.com/corymsmith/react-native-fabric/issues/225, which still remains unanswered.
I started giving it a try by forking the repo and understanding the auto link process given by react native.
In the package.json of the node_module package i replaced
"rnpm": {
"android": {
"packageInstance": "new FabricPackage()"
}
},
with file in the package root react-native.config.js
module.exports = {
dependencies: {
'react-native-fabric': {
platforms: {
android: {
"packageImportPath": "import com.smixx.fabric.FabricPackage;",
"packageInstance": "new FabricPackage()"
}
}
}
}
};
I also updated the build gradle to 3.4.1 from 3.1.0
My react native app is able to now find the package.
But when i call the package in my react component i get NoClassDefFoundError, which means that class is not found.
Anybody else gave this a try and have a solution please let me know.
Try to unlink with react-native unlink and then re run your code again.
Putting it here from the above comment to make it more clear:
Ok i got this to work by changing the forked repo -> (adding a react-native.config.js in the root of the package with with auto discovery and link configurations), but i think the only scalable solution i see right now is to degrade to RN ^59.0 as not a lot of packages have auto link config changes. So will wait for RN 60.4 to mature and then upgrade to it in about a month. In addition to this fabric is currently migrating to firebase and plans to complete by year end. This mean that anyways the sdk integration is going to be obsolete and hence this package too.
Also this issue is majorly related to react-native-fabric and not RN itself.

React Native Navigation installation issue with React Native v0.51

I am having problem with the installation of the React Native Navigation with React Native v0.51. I saw that there are changes made to the index.ios and index.android file in favor of only one index.js file. I have made changes accordingly in AppDelegate.m but it still does not work.
AppDelegate.m
App boot up stuck in 4/478
Mine is working fine with the same changes that you've made in your AppDelegate.m file like yours. But, I am still unable to get android running.
While changing my AppDelegate.m file, xcode was unable to find the RCTBundleURLProvider.h so I had to re-link React under Product > Schema > Manage Schema
For android: Adding the following method inside MainApplication class of MainApplication.java worked for me.
#Override
public String getJSMainModuleName() {
return "index";
}