嗨,我正在使用react native firebase进行通知,我成功集成了它,并且两种平台的通知都来了,但是当应用程序处于前台或后台时,对于Android的提示并没有到来。我阅读了与此有关的所有问题,但没有任何线索。
应用环境:
所以当应用程序在前台应用程序时,需要处理我正在做的通知:
componentDidMount() {
this.checkFirebase();
}
registerFbCloudMessagingListener = () => {
firebase.notifications().onNotification(notification => {
if (Platform.OS === "android") {
notification.android.setChannelId("forgroundnotification");
}
firebase.notifications().displayNotification(notification);
});
};
async checkFirebase() {
const enabled = await firebase.messaging().hasPermission();
if (enabled) {
// user has permissions
this.registerFbCloudMessagingListener();
} else {
// user doesn't have permission
this.requestFbPermission();
}
}
async requestFbPermission() {
try {
let permission = await …Run Code Online (Sandbox Code Playgroud) android firebase react-native firebase-cloud-messaging react-native-firebase
嗨,我正在编写一个从Android 4.4.4版到最新版的react native应用。我遇到的情况是需要下载数百万条记录,然后存储到本地数据库(使用西瓜数据库)。我正在使用xhr请求对记录进行分页并获取数据(一次拍摄10000个)。
提取和存储都是异步操作。我可以使用循环或递归来做到这一点。
递归代码段:
dataFetch = async () => {
if (maxPages && page > maxPages) {
return true;
}
const { data } = await axios.get(API_GET_RECORDS, {
params: {
page,
per_page: 10000,
},
});
if (data.data && data.data.length === 0) {
return true;
}
await addIntoDatabase(this.props.database, data.data);
if ((maxPages || data.max_pages) && page) {
this.setState({
message: `Loading ${Number.parseFloat(
(page * 100) / (maxPages || data.max_pages),
)}%`,
});
// console.log((page * 100) …Run Code Online (Sandbox Code Playgroud)