Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dakeshi on github.
  • I am dakeshi (https://keybase.io/dakeshi) on keybase.
  • I have a public key ASCfKqtJR28WR4wENx8E5uWzS0COT_m0Gt2wwu5dPd-jswo

To claim this, I am signing this object:

$ go env | grep GOPATH
GOPATH=`/Users/UserName/go`
/*:
* [How to make custom iterator](https://academy.realm.io/posts/try-swift-soroush-khanlou-sequence-collection/)
* [Implementation of a LinkedList using enum](https://github.com/apple/swift/blob/master/stdlib/public/core/Sequence.swift)
*/
import Foundation
indirect enum LinkedListNode<T> {
case value(element: T, next: LinkedListNode<T>)
case end
}
@dakeshi
dakeshi / iOS10_remote_push_notification.adoc
Last active June 15, 2018 06:58
iOS10 remote push notification

iOS 10 Remote Notification

In iOS 10, there are big changes in the notification. Remote and local notification methods are unified. You can add media such as image using notification extension. In this article, I will talk about how to set up notification types and register the remote notification. And I will show you how to handle remote notification and the actionable notification in the next section.

Remote Notification Process

First, it is helpful to know about how to work remote notification. Remote notification involves the following steps:

  1. Configure your notification types and register the remote notification

  2. Register remote notification to APNs

@dakeshi
dakeshi / Clean web data in WKWebView
Created June 10, 2016 06:17
Use an default WKWebView save all caches, cookies data in the app. So it make very critical issue such as infinite increase app size.
/// In AppDelegate.swift
/// Execute remove webdata method when the app receives the memory warning.
///
/// We can not avoid the infinitely get increased the app size issue
/// when users keep the web searching using the WKWebView.
/// So, you would get iOS full storage message.
///
/// Set WKWebsiteDataStore.nonPersistentDataStore in the configuration
/// can make lightweight WKWebView. But it can not apply every web site.
/// Imagine the web sites used the localStorage, IndexedDB features.
@dakeshi
dakeshi / WKWebView_open_new_window.swift
Last active July 7, 2016 09:17
open Safari app in response to JS window open, target = _blank tag
// confirm : WKUIDelgate protocol
// To dealt with JS window open or target = _blank tag
// - result : open Safari app
func webView(webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
if UIApplication.sharedApplication().canOpenURL(navigationAction.request.URL!) {
UIApplication.sharedApplication().openURL(navigationAction.request.URL!)
}
@dakeshi
dakeshi / WKWebView_Display_UI_panel_for_JavaScript.swift
Last active March 21, 2016 07:35
WKUIDelegate provides native UI elements instead of webpage. For example, you can display UIAlertController in response to JavaScript confirm function. You need to confirm WKUIDelegate protocol before using it.
// confirm : WKUIDelegate protocol
webView.UIDelegate = self
…..
** javascript popup box test
// let alert_box_url = "http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert"
// let confirm_box_url = "http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm"
@dakeshi
dakeshi / WKWebView_tel_sms_mailto_tags_and_appstore_connection.swift
Last active June 20, 2022 00:47
Detect tel, sms, mailto tags in WKWebView
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
let url = navigationAction.request.URL?.absoluteString
let hostAddress = navigationAction.request.URL?.host
// To connnect app store
if hostAddress == "itunes.apple.com" {
if UIApplication.sharedApplication().canOpenURL(navigationAction.request.URL!) {