构建编号是指编译构建的版本号,通常用于标识不同的 App 版本。在 App Store 中,我们可以在版本信息中看到构建编号。针对 iOS,我们可以通过代码获取当前应用的构建编号:
if let buildVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String {
print("当前应用的构建编号为:\(buildVersion)")
}
而在 React Native 中,我们则可以这样获取:
import {NativeModules} from 'react-native';
const AppInfo = NativeModules.AppInfo;
console.log("当前应用的构建编号为:" + AppInfo.buildVersion);