This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>My Web Application</title> | |
</head> | |
<body> | |
<div id="update-banner" data-state="noupdate"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CACHE_NAME = 'my-web-app-version-v3'; | |
self.addEventListener('install', event => { | |
event.waitUntil( | |
caches.open(CACHE_NAME) | |
.then(cache => { | |
return cache.addAll([ | |
'./', | |
'./index.php', | |
'./ServiceWorkerUpdateListener.min.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>My Web Application</title> | |
</head> | |
<body> | |
<div id="update-banner" data-state="noupdate"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CACHE_NAME = 'my-web-app-version-v1'; | |
// 1 - Install | |
// Here we wait for an InstallEvent to fire, then tell the cache which URLs it should retrieve and cache | |
self.addEventListener('install', event => { | |
event.waitUntil( | |
caches.open(CACHE_NAME) | |
.then(cache => { | |
return cache.addAll([ | |
'./', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
import CommonCrypto | |
class TwitterAPI: NSObject, ObservableObject { | |
@Published var authorizationSheetIsPresented = false | |
@Published var authorizationURL: URL? | |
@Published var user: User? | |
private var tokenCredentials: TokenCredentials? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import SafariServices | |
struct SafariView: UIViewControllerRepresentable { | |
class SafariViewControllerWrapper: UIViewController { | |
private var safariViewController: SFSafariViewController? | |
var url: URL? { | |
didSet { | |
if let safariViewController = safariViewController { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
struct ContentView: View { | |
@EnvironmentObject var twitterAPI: TwitterAPI | |
var body: some View { | |
VStack { | |
if let screenName = twitterAPI.user?.screenName { | |
Text("Welcome").font(.largeTitle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
struct TwitterTutorialApp: App { | |
@StateObject var twitterAPI = TwitterAPI() | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
.environmentObject(twitterAPI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.subscriptions["oAuthAccessTokenSubscriber"] = | |
self.oAuthAccessTokenPublisher(temporaryCredentials: temporaryCredentials, | |
verifier: oAuthVerifier) // 1 | |
.receive(on: DispatchQueue.main) // 2 | |
.sink(receiveCompletion: { _ in // 3 | |
// Error handler | |
}, receiveValue: { [weak self] (tokenCredentials, user) in // 4 | |
guard let self = self else { return } | |
// 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var tokenCredentials: TokenCredentials? |
NewerOlder