iOS上带有wix导航的codepush

时间:2019-07-12 18:52:32

标签: react-native react-native-navigation visual-studio-app-center code-push react-native-code-push

我已经坚持了两天,即使有人问了这个问题。没有答案对我有帮助。

我正在使用Wix Navigation V2,并尝试使用CodePush进行即时更新。在分阶段中,我可以看到CodePush日志和更新发生(只是检查以查看日志)。但是,在正式版中,启动后我的应用始终会恢复为黑屏。到目前为止,这是我尝试过的。

此方法:Is it anyway to get ftpsState of azure web app (Azure Function app) using Python SDK?

我还使用以下命令确保我的plist文件中的部署密钥正确无误 all_vms = client.virtual_machines.list_all()

我也尝试过这些方法 https://medium.com/react-coach/using-codepush-with-wix-react-native-navigation-a6a7938cee24

这是我的App.js代码

appcenter codepush deployment list -a {myUserName}/{appName} -k

这是我注册屏幕并用codepush包装HOC的地方

  TODO: 
  SET ORIENTATION
*/

import { NetInfo, Platform } from "react-native";
import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import { Provider } from "react-redux";
import thunk from "redux-thunk";
import { Navigation } from "react-native-navigation";
import codePush from "react-native-code-push";
import { registerScreens, registerScreenVisibilityListener } from "./screens";
import rootReducer from "./redux/reducers/index";
import { connectionStatusChanged } from "./redux/actions";

const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(thunk))
);

registerScreens(store, Provider);
registerScreenVisibilityListener();

const handleConnectivityChange = reach => {
  store.dispatch(connectionStatusChanged(reach));
};

NetInfo.addEventListener("connectionChange", handleConnectivityChange);

export default class App {
  constructor() {
    store.subscribe(this.onStoreUpdate.bind(this));

    NetInfo.getConnectionInfo().then(reach => {
      handleConnectivityChange(reach);
    });
  }

  onStoreUpdate = () => {
    const { appRoot } = store.getState().appState;

    if (this.currentRoot !== appRoot) {
      // CODE PUSH SYNC
      codePush.sync({
        updateDialog: true,
        installMode: codePush.InstallMode.IMMEDIATE
      });
      this.currentRoot = appRoot;
      this.startApp(appRoot);
    }
  };

  startApp = root => {
    // ALL MY RNN V2 SCREENS (REMOVING TO REDUCE CODE)
  } 

}

最后,这是我的AppDelegate.m

import React from "react";
import _ from "lodash";
import { Provider } from "react-redux";
import { Linking } from "react-native";
import { Navigation } from "react-native-navigation";
import codePush from "react-native-code-push";
import NavigationActions from "../navigation/navigationActions";


const codePushOptions = { checkFrequency: codePush.CheckFrequency.MANUAL };

function wrap(WrappedComponent, store) {
  class PP extends React.PureComponent {
    componentWillMount() {
      Linking.addEventListener("url", this.deeplinkHandler);
      Linking.getInitialURL().then(url => {
        // FUNCTION HERE TO ROUTE TO ARTICLE, STRAIN, PRODUCT (when ap is closed)

        if (url) {
          const linkData = url.replace("weedup://", "").split("/");
          if (this.props.componentId === "home" && linkData[0] === "article") {
            // push component
            const { componentId } = this.props;
            NavigationActions.pushComponent({
              id: "home",
              name: "screen.Article",
              props: {
                fromDeepLink: true,
                fromBackground: false,
                article: {
                  id: linkData[1]
                }
              },
              title: "Article",
              topBarVisible: true,
              bottomTabsVisible: false
            });
          }
        }
      });
    }

    deeplinkHandler = event => {
      // FUNCTION HERE TO ROUTE TO ARTICLE, STRAIN, PRODUCT (opened)
      if (!_.isEmpty(event)) {
        const linkData = event.url.replace("weedup://", "").split("/");
        if (this.props.componentId === "home" && linkData[0] === "article") {
          const { componentId } = this.props;
          NavigationActions.pushComponent({
            id: "home",
            name: "screen.Article",
            props: {
              fromDeepLink: true,
              fromBackground: true,
              article: {
                id: linkData[1]
              }
            },
            title: "Article",
            topBarVisible: true,
            bottomTabsVisible: false
          });
        }
      }
    };

    render() {
      return (
        <Provider store={store}>
          <WrappedComponent {...this.props} />
        </Provider>
      );
    }
  }

  return codePush(codePushOptions)(PP);
}

export const registerScreens = store => {
 // REMOVING SCREEN TO REDUCE EXAMPLE CODE
};

export function registerScreenVisibilityListener() {
  Navigation.events().registerComponentDidAppearListener(
    ({ componentName }) => {
      console.log(`Displaying screen ${componentName}`);
    }
  );
}

2 个答案:

答案 0 :(得分:0)

嘿,也许我来晚了,但是由于我在将RNN与CodePush集成时偶然发现了您的问题,所以我想把它放在这里。

在DEBUG中,当 not 时,您似乎没有使用RNN,因此我只需将您的didFinishLaunchingWithOptions函数替换为:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

#ifdef DEBUG
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  jsCodeLocation = [CodePush bundleURL];
#endif

  [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];

  return YES;
}

答案 1 :(得分:0)

您还可以使用Expo实现热更新,这是带有Expo更新和React Native导航的工作示例。该项目未附加到Expo CLI,因此您可以在React Native项目中使用它

https://github.com/samithaf/expo-sample-app