Can we run firebase realtime listening on ios serviceworker?

余生长醉 提交于 2019-12-28 12:47:03

问题


As of iOS 11.3 there is serviceworker feature supported

Even though it has no support for notification. I wonder if it possible to just run any realtime listener, such as firebase database, to receive realtime data and use ServiceWorkerRegistration.showNotification to show local notification instead

Is it possible?


回答1:


While iOS don't support Web Push notifications yet(as of Apr-2018), all you can do is have an event listener for data from server side(Firebase in your case) and receive that data to show it as an Notification/alert or how ever you want to present inside your application(not in iOS notification area).

Unfortunately, this is the best way you can handle notifications for iOS. I know, its not so great for developers :) Hope Apple speeds up on PWA. They are more than a year late to Service worker party itself. What to expect!

Update : One more link on WhatWebCanDo.today and one from Apple which says iOS-Safari don’t support push notification as a web standard defined by w3c. But looks like there is a OS X safari proprietary solution available.




回答2:


Unfortunately not, while Safari on native IOS is getting closer to the functionality we see in chrome, firefox etc. we currently ( as of this comment ) do not have anyway of sending push notifications on native IOS Safari ( or any other ios browser like chrome etc. ).

Safari for mac uses a custom mac solution for these notifications which you can check out here https://developer.apple.com/notifications/safari-push-notifications/.




回答3:


If you're using firebase then you will find push notification in main terminal of your firebase project and you won't be able to run service worker javaScript on it for offline data handling but you can use it for push notification. can you explain more about question be brief.!



来源:https://stackoverflow.com/questions/49745221/can-we-run-firebase-realtime-listening-on-ios-serviceworker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!