How to handle HTML5 Web Notifications with a Cocoa WebView? - cocoa

I use a Cocoa WebView to display a website which sends HTML5 Web Notifications. When browsing this page using Safari, I receive User Notifications directly in the Notification Center of Mac OS X Mountain Lion.
How I can achieve the same behavior by implementing my own WebView ? I didn't see any delegate methods related to this feature.
Edit: If this can help someone:
https://github.com/jnordberg/irccloudapp/blob/master/NotificationProvider.m
Thanks to Johan Nordberg for sharing this.

There is no public API for web notifications in WebKit on OS X at this time. You should file an enhancement request with Apple requesting that the functionality be exposed. However, since WebKit is open source you can easily find the private interface on WebView that relates to displaying web notifications. As with all private interfaces, it's subject to change without notice and may not be used within an application in the App Store.

Related

Xamarin forms Webview via websocket

I developed xamarin forms application with WebView which routing to page with signalR websocket. And when page is loaded connection doesn't start. I have read about android.webview doesn't support websocket. Can someone give me advice about implimintation of websocket via webview. maybe use custom webview or something else.
I read that webview doesn’t allow WebSocket on android version less then 4.0. In my case my webview cached the page that I used before added the WebSocket and when I clear the cache all works fine

Import IOS SMS and iMessage Messages in Xamarin IOS

I've been digging around on the internet but haven't found anything close to what I'm looking for. Is there any way to load all SMS and iMessage messages into a custom Xamarin IOS app. I don't want to send or receive messages, just view messages that are already on the phone or tablet.Even if there is a Xamarin Forms solution for accessing existing messages, that would work.
There is no way to read SMS messages due to privacy concerns.
you have to Log in to the developers portal and click App Store Review Guidelines.
Nowhere in the guidelines does it specify that you can't access the SMSes. But you can only access then if you use private methods which is not allowed and will get you app rejected.
You can only access data for which Apple supplies a documented API. You can not access file outside of the Sandbox of your App, unless Apple provides an API for it.

Fallback for missing custom tabs with Xamarin and Azure AD B2C

I followed the sample on Xamarin Authorization with Azure AD B2C
That uses Custom Chrome Tabs (and the Safari equivalent).
I do not find any resources on how to handle the case if no Chrome is installed on the mobile device. I just noticed in emulator, it just raises an error dialog that Chrome must be installed. But I do not want to exclude users from signing in/up that use alternative browsers.
Are there any links/tutorials that cover this (crucial) behavior?
MSAL now suports a fallback using the embedded browser of Android / iOS:
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/msal-net-2-released#you-can-now-leverage-the-embedded-web-browser-in-xamarinios-and-xamarinandroid
You can now leverage the embedded web browser in Xamarin.iOS and
Xamarin.Android
In the previous versions of MSAL.NET, Xamarin.Android and Xamarin.iOS
used the System web browser interacting with Chrome tabs. This was
great if you wanted to benefit from SSO, but that was not working on
some Android phones which device manufacturers did not provide Chrome,
or if the end user had disabled Chrome. As an app developer, you can
now leverage an embedded browser. To support this, the UIParent class
now has a constructor taking a Boolean to specify if you want to
choose the embedded browser. It also has a static method,
IsSystemWebviewAvailable(), to help you decide if you want to use it.
For instance, on Android: bool useSystemBrowser =
UIParent.IsSystemWebviewAvailable(); App.UIParent = new
UIParent(Xamarin.Forms.Forms.Context as Activity, !useSystemBrowser);
For more details about this possibility see the article in MSAL's
conceptual documentation: https://aka.ms/msal-net-uses-web-browser.
Also the web view implementation might change in the future
You will have to use a different library such as:
AppAuth for Android
"When a Custom Tabs implementation is provided by a browser on the device (for example by Chrome), Custom Tabs are used for authorization requests. Otherwise, the default browser is used as a fallback."
AppAuth for iOS
"iOS 9+ uses the in-app browser tab pattern (via SFSafariViewController), and falls back to the system browser (mobile Safari) on earlier versions."
(Note that Microsoft Authentication Library is consistent with the IETF's Best Current Practice for OAuth 2.0 for Native Apps that:
"... the best current practice is to perform the OAuth authorization request in an external user agent (typically the browser) rather than an embedded user agent (such as one implemented with web-views)."

Cocoa app intercepting http links

Is it possible for a Cocoa app to handle http://somedomain.com links, but ignore other domains? If my app is running, I want it to handle links to http://somedomain.com only.

Session state persistence between web page content and XmlHttpRequest for Mac dashboard widgets and Safari extensions

I already posted to Apple's Safari dev forum but got no responses so thought try cross posting elsewhere to get ideas:
I'm asking this question in regards to both
Safari Extension (toolbar type AJAX extension)
Mac OS X dashboard widget
I assume both will be similar as they use the WebKit rendering engine?
I would like to know if the engine for maintaining built in session state support (cookies?) shares and persists the session between web content loaded on the page by the browser engine (HTML, JS, CSS, images, etc.) and requests made by XmlHttpRequest object.
I'm porting an AJAX app that requires session state that's shared between web content and XmlHttpRequest object. (i.e. no explicit cookie management for session state, at least not defined by the web service API that I use).
I successfully ported the app to Chrome, Opera, Windows 7/Vista gadget. It failed to work on iGoogle, and Mac OS X widget. Safari extension port had mixed results - it works in some cases but not in others.
I also did a Microsoft .HTA port (HTA app = web app to be run via IE w/o security restrictions of normal web apps, like cross domain XmlHttpRequests) and noticed that works only with IE7+ (due to implementation differences of native XmlHttpRequest in IE7+ vs MS XML version of earlier IEs)
I had consulted discussion/support group for iGoogle as well and learned that iGoogle too doesn't support such session state support.
I kind of worked around iGoogle issue by using Flash component to perform XmlHttpRequests which seemed to be able to share the overall browser session and thus work. I'm attempting that for Mac widget, it didn't seem to work. Can Safari toolbar extensions make use of Flash?
In any case posting this thread for more insight like if Safari/Mac is like iGoogle and not support a shared session between web content and XmlHttpRequest (or no cookies even supported).
FYI, the app I'm working on is below, you can try out what I have to investigate issue. When session state support fails, you get error message that need to enter code correctly (that's what the web service returns in this case, not very helpful to the user).
http://code.google.com/p/autosmsclients/
I've already hosted code for Mac OS X widget and Safari extension there.

Resources