标签: react-native-ios

重置推送通知/设备注册/实例 ID - 通过 TestFlight 或 App Store 进行应用程序更新 - Firebase 云消息传递 iOS/React Native Firebase

关于这个问题做了很多研究,首先是我的设置:

我的问题非常简单直接,尽管我似乎无法找到解决问题的明确方法。

我部署了应用程序的 4.2 版本。iOS 中的 Firebase 云消息传递 (FCM) 运行得非常好。然后我将 4.3 部署到 TestFlight 开始测试。通过 TestFlight 安装 4.3,FCM 停止工作,没有推送通知。如果我删除该应用程序并通过 TestFlight 推送通知再次安装 4.3,则该设备已注册。

我还可以重现此问题,更新最新发布的 App Store 中我的应用程序的安装版本,这并不奇怪。

我知道 InstanceId/设备令牌基于应用程序构建+设备,因此当应用程序更新时令牌发生变化是有意义的,但当我从 4.2 更新到 4.3 时我的令牌是相同的:

const fcmToken = await firebase.messaging().getToken(); //same whether 4.2 or 4.3
Run Code Online (Sandbox Code Playgroud)

是的, firebase.messaging().getToken() 在初始创建时被缓存。

所以我准备监听令牌更改事件:

firebase.messaging().onTokenRefresh(async () => {
  console.log('======onTokenRefresh=========');
  AsyncStorage.removeItem(FCM_TOKEN_KEY);
  await getToken();
});
Run Code Online (Sandbox Code Playgroud)

那似乎永远不会火。我什至在我的应用程序中添加了一个按钮,以尝试强制使用新的 InstanceId 并在从 TestFlight 或 AppStore 更新版本后向 FCM 注册,但这没有帮助:

export async function forceRefresh() {
  console.log('================force a new registration!!!==========');
  AsyncStorage.removeItem(FCM_TOKEN_KEY);
  firebase.messaging().deleteToken(); …
Run Code Online (Sandbox Code Playgroud)

ios firebase reactjs react-native react-native-ios

1
推荐指数
1
解决办法
5143
查看次数

ViewPager 和 FlatList 有什么区别?

我认为 FlatList 的 pagingEnabled={true} 与 viewpager 的贡献相同。两者有何区别?

android-viewpager react-native react-native-ios react-native-flatlist

1
推荐指数
1
解决办法
985
查看次数

在 iOS 上运行排毒测试时模拟器无法打开

当我尝试运行detox test模拟器时,模拟器似乎没有打开,并且测试只是超时。

我确认我的设置是正确的,并尝试这样做以确保我的模拟器可以从终端启动,并且我的detox配置中的设备类型是正确的。

我收到的错误如下。

Timeout - Async callback was not invoked within the 300000ms timeout specified by jest.setTimeout.
Error: Timeout - Async callback was not invoked within the 300000ms timeout specified by jest.setTimeout.
Run Code Online (Sandbox Code Playgroud)

DetoxRuntimeError: Detox instance has not been initialized

HINT: There was an error on attempt to call detox.init()

DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()

HINT: Most likely, your test runner is tearing down the suite due to the timeout …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios detox

1
推荐指数
1
解决办法
2371
查看次数

React Native 设置默认 iPhone 模拟器

我想为我的 React Native 项目设置一个默认模拟器,这样如果我运行脚本 yarn iosnpx react-native run-ios它总是启动“iPhone 12 Pro Max”。

  • 使用该--simulator标志一次不会更改默认模拟器,下次运行yarn iosreact-native run-ios它在不同的模拟器上启动时
  • 当我运行yarn ios应用程序时,以 开头iPhone 10,当我运行npx react-native run-ios应用程序时,以 开头iPhone 8。如果我通过 xCode 删除其中任何一个模拟器,该项目将不会使用提到的脚本启动,并会抛出找不到 iPhone 10 或 iPhone 8 的错误。

所以我的问题是项目中这些模拟器的值保存在哪里,以及如何更改它。它是否设置在.xcworkspace或的某个地方.xcodeproj?如果有人克隆此项目并运行该应用程序,则该应用程序可能会在其计算机上的不同设备上启动。

注意:我不是在寻找答案,包括设置--simulator标志

xcode ios ios-simulator react-native react-native-ios

1
推荐指数
1
解决办法
3471
查看次数

React Native 项目未在使用 Apple M1 芯片的 iOS 模拟器上运行

我对 React Native 并不陌生,已经研究这个问题有一段时间了,但我现在面临的问题几乎是新的。我厌倦了这个问题。我面临的问题是,我无法在 iOS 模拟器上运行该应用程序。我几乎尝试了所有方法来解决这个问题,但都无法解决。

我的考验:

  1. 删除Pods然后Podfile.lockpod install然后react-native run-ios
  2. 删除node_modules然后package-lock.json然后PodsPodfile.lock然后做npm install-> pod install->react-native run-ios
  3. 打开 Xcode,清理 Build,然后react-native run-ios
  4. 运行react-native start --reset-cache然后react-native run-ios
  5. pod update然后react-native run-ios

它仍然失败,并且在控制台上抛出了很多错误。我对这种情况感到困惑和恐惧。直到早上一切都工作正常,但现在什么都不起作用了

我得到的错误:

I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/React-jsi -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/React-jsiexecutor -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/React-jsinspector -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/React-perflogger -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/React-runtimeexecutor -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/ReactCommon -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/Yoga -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/glog -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/boost-for-react-native -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/RCT-Folly -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/DoubleConversion -I/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Private/React-Core -I/Users/careerlabsdev/Library/Developer/Xcode/DerivedData/SpaceX-gxgruwmfuircbegvjpqyszccmuiz/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/DerivedSources-normal/x86_64 -I/Users/careerlabsdev/Library/Developer/Xcode/DerivedData/SpaceX-gxgruwmfuircbegvjpqyszccmuiz/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/DerivedSources/x86_64 -I/Users/careerlabsdev/Library/Developer/Xcode/DerivedData/SpaceX-gxgruwmfuircbegvjpqyszccmuiz/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/DerivedSources -F/Users/careerlabsdev/Library/Developer/Xcode/DerivedData/SpaceX-gxgruwmfuircbegvjpqyszccmuiz/Build/Products/Debug-iphonesimulator/ReactCommon -fmodule-map-file\=/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/React/React-Core.modulemap -fmodule-map-file\=/Users/careerlabsdev/Documents/Projects/SpaceX/ios/Pods/Headers/Public/yoga/Yoga.modulemap -DFOLLY_NO_CONFIG -DFOLLY_MOBILE\=1 -DFOLLY_USE_LIBCPP\=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation …
Run Code Online (Sandbox Code Playgroud)

xcode build-error ios react-native-ios apple-m1

1
推荐指数
1
解决办法
7539
查看次数

获取在 React Native ios 中不起作用

我在 React Native 中有登录功能,我尝试在其中获取数据。功能如下:

onLogin: function() {  //
        const self = this;
        self.setState({modalVisible: true, modalMessage: 'Signing in'});
        fetch('http://psa.autralis.com/manager/api/v1/obtain-auth-token/', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                username: self.state.username,
                password: self.state.password,
            })
        })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch((error) => {
                console.warn(error);
            });
    },
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,它不适用于ios。我收到一个错误:

在此处输入图片说明

在 android 上它可以工作,我用邮递员对其进行了测试,它也可以工作。

任何的想法?

react-native fetch-api react-native-ios

0
推荐指数
1
解决办法
3545
查看次数

react-native-elements:标题呈现意外的底部边框

我遇到了来自 react-native-elements 的 Header 组件的奇怪问题。这是我所看到的: 在此处输入图片说明

这是代码:

<Header
    leftComponent={{ icon: 'menu', color: '#85106a',  }}
    rightComponent={<Avatar
        small
        rounded
        source={{uri: "https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg"}}
        onPress={() => console.log("Works!")}
        activeOpacity={0.7}
    />}
    statusBarProps={{ barStyle: 'dark-content', translucent: true }}
/>
Run Code Online (Sandbox Code Playgroud)

我希望底部的边框与汉堡菜单的颜色相同。我查看了组件的文档,但没有找到任何实质内容。

任何想法都非常感谢。谢谢

reactjs react-native react-native-ios

0
推荐指数
2
解决办法
3429
查看次数

元素类型无效,您可能忘记了导出组件

尝试在iOS模拟器上运行代码时出现以下错误。该错误指出“元素类型无效:应使用字符串(对于内置组件),但得到:未定义。您可能忘记了从定义文件中导出组件。”

我在其他人的帖子上看到过同样的问题,他们需要在文件末尾添加“导出默认应用程序”或在类的声明中使用“导出默认类”。

我正在关注的教程是https://medium.com/@gurusundesh/getting-started-with-react-native-mapview-5e0bd73aa602。从那以后,这可能是该文章过时了,本机也发生了变化。

任何有关如何解决此问题的建议将不胜感激。

谢谢

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
import { MapView } from 'react-native-maps';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

class App extends Component { …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-ios

0
推荐指数
1
解决办法
724
查看次数

在React Native中,可以在键盘打开时调用onPress

用户需要在点击两次FlatList项目,因为autoFocus={true}<TextInput。第一次单击时,键盘处于隐藏状态,然后单击呼叫onPress={this.GetItem.bind(this, item)}。是否可以选择GetItem()单击一次而不是单击两次。

演示:https//snack.expo.io/ByJ_yWehM

export default class App extends Component {
  GetItem (item) {
    console.log(item);
    Alert.alert(item);
  }
  render() {
    return (
      <View style={styles.container}>
        <TextInput
          autoFocus={true}
          style={styles.paragraph}
          keyboardType='web-search'
        >
          Change code in the editor and watch it change on your phone!
          Save to get a shareable url.
        </TextInput>
        <Card title="Local Modules">
          <View>
            <TextInput
              style={styles.searchField}
              placeholder="Type here to translate!"
              onChangeText={(text) => this.setState({text})}
            />

            <FlatList
                data={["akin","alike","close","comparable","like","similar","uniform","Allied","Analogous","Co-ordinate","Commensurate","akin","alike","close","comparable","like","similar","uniform","Allied","Analogous","Co-ordinate","Commensurate"]}
                renderItem={({item}) => (
                  <Text
                    style={styles.listField} …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-native-ios react-native-flatlist

0
推荐指数
1
解决办法
994
查看次数

签署“ appnameTest”需要开发团队。在项目编辑器中选择一个开发团队。(在目标“ appnameTest”中)

当我尝试在Xcode中运行全新安装的React本机项目时,出现此错误。

虽然我已经添加了一个开发者帐户来进行签名。我的Xcode版本是10.0(10A255)

在此处输入图片说明

xcode ios react-native react-native-ios

0
推荐指数
1
解决办法
3276
查看次数