private void CreateReactView()
        {
            if (RendererManager.Debug && !Settings.CanDrawOverlays(RendererManager.Activity))
            {
                // Debug mode without overlay permissions not supported.
                System.Console.WriteLine("[ReactNative.Forms] Debug mode without overlay permissions not supported.");
                return;
            }

            _rootView        = new ReactRootView(Context);
            _instanceManager = ReactInstanceManager.Builder()
                               .SetApplication(RendererManager.Activity.Application)
                               .SetBundleAssetName(Element.BundleName)
                               .SetJSMainModulePath(Element.ModulePath)
                               .AddPackage(new MainReactPackage())
                               .SetUseDeveloperSupport(RendererManager.Debug)
                               .SetInitialLifecycleState(LifecycleState.Resumed)
                               .Build();

            _instanceManager.AddReactInstanceEventListener(this);

            // convert dictionary to bundle
            var props = new Bundle();

            foreach (KeyValuePair <string, object> entry in Element.Properties)
            {
                props.PutString(entry.Key, (string)entry.Value);
            }

            _rootView.StartReactApplication(_instanceManager, Element.ModuleName, props);
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                if (!Settings.CanDrawOverlays(this))
                {
                    Intent intent = new Intent(Settings.ActionManageOverlayPermission, Uri.Parse("package:" + PackageName));
                    StartActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
                }
            }

            mReactRootView        = new ReactRootView(this);
            mReactInstanceManager = ReactInstanceManager.Builder()
                                    .SetApplication(Application)
                                    .SetBundleAssetName("index.android.bundle")
                                    .SetJSMainModulePath("index")
                                    .AddPackage(new MainReactPackage())
                                    .AddPackage(new ApiPackage())
                                    .AddPackage(new SvgPackage())
#if DEBUG
                                    .SetUseDeveloperSupport(true)
#else
                                    .SetUseDeveloperSupport(false)
#endif
                                    .SetInitialLifecycleState(LifecycleState.Resumed)
                                    .Build();

            mReactRootView.StartReactApplication(mReactInstanceManager, "MyReactNativeApp", null);

            SetContentView(mReactRootView);
        }
        private void startReactNative()
        {
            mReactRootView        = new ReactRootView(this);
            mReactInstanceManager = ReactInstanceManager.Builder()
                                    .SetApplication(Application)
                                    .SetBundleAssetName("index.android.bundle")
                                    .SetJSMainModulePath("index")
                                    .AddPackage(new MainReactPackage())
#if DEBUG
                                    .SetUseDeveloperSupport(true)
#else
                                    .SetUseDeveloperSupport(false)
#endif
                                    .SetInitialLifecycleState(LifecycleState.Resumed)
                                    .Build();

            mReactRootView.StartReactApplication(mReactInstanceManager, "MyReactNativeApp", null);

            SetContentView(mReactRootView);
        }