目前,如果我们想要使用以下方法将设备添加到SNS应用程序:
ep = SNSConnection.create_platform_endpoint(app_arn,device_token,user_data)
Run Code Online (Sandbox Code Playgroud)
有一个选项,该设备已在过去添加.要验证设备是否已添加,我们正在使用:
def is_device_registered(device_token):
list_of_endpoints = SNSConnection.list_endpoints_by_platform_application(AC.INPLAY_CHAT_APPLICATION_SNS_ARN)
all_app_endpoints = list_of_endpoints['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']
for ep in all_app_endpoints:
ep_device_token = ep['Attributes']['Token']
if device_token == ep_device_token:
endpoint_arn = ep['EndpointArn']
print 'Found an endpoint for device_token: %s, entry:%s' % (device_token,endpoint_arn)
return endpoint_arn
return None
Run Code Online (Sandbox Code Playgroud)
这是非常低效的,无法缩放.
是否有一个boto sns函数获取device_token并返回endpoint_arn(如果存在)?(如果没有,则为无).
我一直在尝试使用React Native,我无法将对导航器的引用传递到我正在渲染的场景中.没有导航器,NewsList项目不能触发场景更改.
render: function() {
return (
<Navigator
initialRoute={ { name: 'NewsList', index: 0 } }
renderScene={ ( route, navigator ) => NewsList }
/>
);
},
Run Code Online (Sandbox Code Playgroud)
类似地,在渲染场景功能中,我需要将导航器传递给行渲染功能.
<UIExplorerPage noSpacer={true} noScroll={true}>
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderRow}
onEndReached={this.onEndReached}
/>
</UIExplorerPage>
Run Code Online (Sandbox Code Playgroud)
传递这样的引用的惯用方法是什么?
我遇到了一个问题,嵌套 Touchable 中的双击(同时触摸)到达父 Touchable。
在下面的示例中,Touchable 嵌套了三层深。当我按下最深的可触摸(蓝色)时,控制台正确打印“蓝色”。当我按下分别打印“绿色”和“红色”的其他图层时,它的行为也正确。
当我同时进行两次触摸和释放时会出现奇怪的行为 - 然后根本不会调用触摸层的 onPress 。相反,当两个触摸都结束时,父 Touchable 只接收一次触摸。
此外,当我在最外层(红色,没有父级可触摸)执行两个同时触摸时-该层将接收触摸。从我的角度来看,这似乎更正确,但与上述嵌套 Tocuables 中的怪异行为背道而驰。
<View style={{flex:1, backgroundColor:"#666666"}}>
<TouchableHighlight onPress={()=>{console.log("red")}}>
<View style={{backgroundColor:"#FF0000", height:300}}>
<TouchableHighlight onPress={()=>{console.log("green")}}>
<View style={{backgroundColor:"#00FF00", height:200}}>
<TouchableHighlight onPress={()=>{console.log("blue")}}>
<View style={{backgroundColor:"#0000FF", height:100}} />
</TouchableHighlight>
</View>
</TouchableHighlight>
</View>
</TouchableHighlight>
</View>
Run Code Online (Sandbox Code Playgroud) 我正在使用indexOf
React组件来根据对象是否在mobx可观察数组中来设置按钮的样式.
该按钮用于收藏.它将该特定列表项的对象推送到名为"favorites"的商店中的可观察数组中.收藏夹是一个可观察的对象数组.
这是我的按钮中的ES6模板文字:
className={`btn-group ${((this.props.store.favorites.indexOf(this.props.data) > -1)) ? 'success' : 'info'}`}
Run Code Online (Sandbox Code Playgroud)
基本上,它检查对象是否在数组中success
,如果为false,则为className info
.
当收藏夹数组处于本地状态时,这非常正常.但是我发现收藏夹数组中的对象在可观察数组中看起来有所不同.我得到的是可观察数组的收藏夹与本地数组收藏夹不同.
但是,如何测试对象是否在可观察的对象数组中呢?我试过slice()
并peek()
使用findIndex但没有骰子.
我从屏幕 A 导航到屏幕 B..然后导航回屏幕 A 使用
this.props.navigation.goBack(null);
Run Code Online (Sandbox Code Playgroud)
我想知道我们如何在执行此操作时传递参数?
这是我的代码
import React, { Component } from 'react';
import { View, Text, TextInput, ScrollView } from 'react-native';
import Card from './Card';
import CardSection from './CardSection';
import MyButton from './MyButton';
class Settings extends Component{
constructor(props){
super(props);
this.state = {
ip:'',
port:''
};
}
onSaveClick() {
console.log('Button clicked');
this.props.navigation.goBack();
}
render(){
const { input, container } = styles;
return(
<View style = {container}>
<Card>
<CardSection>
<TextInput
style = {input}
onChangeText = {(ip) => this.setState({ip})} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为文本的颜色设置动画,如下所示:
const animateTest = scrollY.interpolate({
inputRange: [0, 100],
outputRange: ['rgba(255,0,0,1)', 'rgba(0,255,0,1)']
});
return (<View>
<Animated.Text style={{ position:'absolute',
color: animateTest
}} >blah blah blah</Animated.Text>
<Animated.ScrollView
scrollEventThrottle={16}
onScroll={Animated.event(
[
{
nativeEvent: {contentOffset: {y: scrollY}},
},
],
{
useNativeDriver: true,
}
)}
>
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
Style property 'color' is not supported by native animated module
使用 ReactNative 0.44.0
根据 这篇博客文章, 它应该可以工作,因为他们说:
Native Animated 目前并非支持您使用 Animated 执行的所有操作。主要限制是您只能为非布局属性设置动画,transform、opacity 和 backgroundColor 之类的东西会起作用,但 flexbox 和 position 属性不会。
但我看到支持的代码中的样式有一个白名单:链接到相关代码 有一个非常有限的白名单:
const STYLES_WHITELIST = {
opacity: true,
transform: true, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将声音添加到我的本地推送通知中.我正在使用RN 0.45.1和react-native-push-notifications 3.0.0
我设法使用默认声音在iOS和Android中安排通知.我没有设法添加自定义声音.
我有mp3类型的声音文件.我尝试了以下方法:
然后:
import notificationSound from '../src/assests/sounds/sound.mps';
PushNotification.localNotificationSchedule({
message: 'Test message',
date: new Date(Date.now() + (60 * 1000)),
repeatType: 'time',
repeatTime: 60 * 1000,
sound: notificationSound,
});
Run Code Online (Sandbox Code Playgroud)
通知是:
PushNotification.localNotificationSchedule({
message: 'Test message',
date: new Date(Date.now() + (60 * 1000)),
repeatType: 'time',
repeatTime: 60 * 1000,
sound: sound.mp3,
});
Run Code Online (Sandbox Code Playgroud) 我无法弄清楚mobx-react ......
如何将mobx observable中的道具传递给mobx反应观察者?
下面的代码不起作用,但我觉得应该这样.谁能告诉我出了什么问题?
let mobxData = observable({information: "this is information"});
@observer class Information extends React.Component {
render() {
console.log(this.props.mobxData.information);
return (
<h1>class: {this.props.mobxData.information}</h1>
)
}
};
const StatelessInformation = observer(({mobxData}) => {
console.log(mobxData.information);
return <h1>stateless: {mobxData.information}</h1>
});
ReactDOM.render(
<div>
<Information/>
<StatelessInformation/>
</div>,
document.getElementById('app')
);
Run Code Online (Sandbox Code Playgroud) 例如,如果我有组件:
import React, { Component } from 'react';
import { Video } from 'expo';
let styles = require('../stylesheet.js');
export default class Player extends Component {
render(){
return(
<Video
ref={this._handleVideoRef}
source={require(//file)}
rate={1.0}
volume={1.0}
muted={false}
useNativeControls
resizeMode="cover"
shouldPlay
style={styles.player} />
)
}
}
Run Code Online (Sandbox Code Playgroud)
我在文档(https://docs.expo.io/versions/latest/sdk/av.html)中看到使用“playbackstatus.didJustFinish”和 onPlaybackStatusUpdate 但他们的例子对我来说没有多大意义。谁能告诉我如何使用我的代码确定视频是否已结束?
我正在使用哨兵报告我的 django 应用程序中发生的错误。
有没有办法在使用类似命令时禁用哨兵错误报告
python manage.py shell
javascript ×6
react-native ×6
mobx ×2
mobx-react ×2
reactjs ×2
amazon-sns ×1
animation ×1
boto ×1
django ×1
expo ×1
python ×1
react-router ×1
sentry ×1