How Do I Send React Application Context From Non React Class?
I need to update status changes like event between android and react native class? public class MessagingService extends FirebaseMessagingService { @Override public voi
Solution 1:
I have somehow solved this. we cannot extend ReactApplicationContext
on FirebaseMessagingService
. This service will be called even when app is not running and we don't have control to add react context.
So I have created a separate module and added the listeners which will update the event data to FBMessagingHelper class.
publicclassFBMessagingPackageimplementsReactPackage{
@OverridepublicList<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = newArrayList<>();
modules.add(newVideoModule(reactContext));
return modules;
}
}
publicclassVideoModuleextendsReactContextBaseJavaModule {
privateReactApplicationContext mContext;
publicVideoModule(ReactApplicationContext reactContext) { // Added into Native Modules
mContext = applicationContext;
}
@ReactMethodpublicvoidonVideoProgress(Bolean status){
FBMessagingHelper.IN_VIDEO_PROGRESS = status
// Store it to public static variable of FBMessagingHelper
}
@Nonnull@OverridepublicStringgetName() {
return"VideoModule";
}
}
Post a Comment for "How Do I Send React Application Context From Non React Class?"