English 中文(简体)
让网络推力通知工作 使用网络视图 在本地和机器人应用程序?
原标题:Make Web push notification work using webview in a native android app?
我有一个响应和推动通知功能的网站。在我的本地和机器人应用程序中,如果我在 WebView 中加载了我的网站,那么通常以铬/freamfox 中的弹出来询问用户是否愿意允许推通知,在WebView中没有出现。显然WebView不会支持应用程序的相同的网络推进通知。我知道如何在应用程序中应用 GCM 或 FCM 来进行移动推动,但是我想知道是否可能仅仅用网络推进通知和机器人网络视图来连接网络推动通知,这样它就可以在我的应用程序中工作,因为它在铬/freamfox等方面正在工作。我尝试的是:在更深入地挖掘这个信息之后,我最后的结论是,作为机器人WebVibVi 支持推动 Api (在 canuse.com的帮助下),现在不可能使用网络浏览来进行网络推动的俱乐部推动。对吗?是否已经有任何应用程序可以这样做?
问题回答
Ow, of course this is possible! I easily implemented push web notifications from one signal in my webview App using crosswalk. Uses crosswalk, extends Main activity to XWalkactivity Put this on on create: OneSignal.startInit(this) .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification) .unsubscribeWhenNotificationsAreDisabled(true) .init(); Yeah, you will have web push notifications working!!!
As I m aware, it s not possible using only WebView . The solution that worked for me was to find whether the website you want to display in the WebView uses WebSockets. If yes, the notification will probably be available in the according WebSocket communication. The workflow is following: Determine WebSocket on the website. You can use Firefox "Inspect Code" and in "Network" tab filter out only WebSocket entries. You can test connection to ws via various tools. Simple-WebSocket-Client for Firefox or command line tool. Simply provide URI to your WebSocket (ws://domain.example/ws). Implement WebSocket client in your application. There s been different posts on how to do that. I ve used this lib to make it nice and clean. Now you are receiving messages from server, such as notifications. Parse them and do whatever you want.




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签