我正在使用 react-native-router-flux 并且我正在尝试在选项卡内添加一个带有场景的选项卡栏,例如双选项卡栏之类的东西。它适用于iOS,但不适用于Android
<Router createReducer={reducerCreate}>
<Scene key="tabbar" tabs={true} style={styles.tabBar}>
<Scene key="tab0" title="nested" icon={TabIcon}>
<Scene key="tabbar2" tabs={true} style={styles.tabBar} icon={TabIcon}>
<Scene key="subtab1" title="subtab1" component={Results} icon={TabIconResults} initial={true} />
<Scene key="subtab2" title="subtab2" component={Results} icon={TabIconResults}/>
<Scene key="subtab3" title="subtab3" component={Results} icon={TabIconResults}/>
</Scene>
</Scene>
<Scene key="tab1" component={TabView} title="Réservations" icon={TabIcon} />
<Scene key="tab2" component={TabView} title="Compte" icon={TabIcon}/>
</Scene>
</Router>
Run Code Online (Sandbox Code Playgroud) 我正在使用 React 开发一个渐进式 Web 应用程序,当新优惠添加到数据库时,它会收到通知。一切正常,我打开网页,要求用户授予启用通知的权限,我们允许他们,安装 PWA,运行它,在数据库中添加新优惠,然后显示带有新优惠的通知(Chrome + Windows 10)。
但问题是,如果 PWA 未运行,我不会收到任何通知。即使 PWA 关闭,我也认为服务工作人员正在后台运行。我缺少什么?
这是我的 notification.ts 文件中的 notificationNewOffer 函数
function notifyNewOffer(newOffer: Offer) {
if ('serviceWorker' in navigator) {
const options = {
body: newOffer.subheading,
icon: './logo192.png',
image: './static/media/placeholder-offer.1bcbf040.png',
vibrate: [100, 50, 200],
badge: './favicon.ico',
tag: 'new-offers',
renotify: true,
actions: [
{ action: 'confirm', title: 'Check offer', icon: '' },
],
};
navigator.serviceWorker.ready.then(swreg => {
swreg.showNotification(newOffer.heading, options);
});
} else {
console.log('no serviceWorker');
}
}
Run Code Online (Sandbox Code Playgroud)
我就是这样称呼它的:
function addedOfferSubs<T>(setOffers: (offers:any) => void) …
Run Code Online (Sandbox Code Playgroud) notifications push-notification reactjs progressive-web-apps aws-amplify