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
//Here starts the function definition and scope | |
func registerForPushNotifications() { | |
//Here we are creating a notifCenter reference for shorter lines of code | |
let notifCenter = UNUserNotificationCenter.current() | |
//Here we access the requestAuthorization method that lives on the | |
//UNUserNotificationCenter. It takes an array of options of an enum type | |
//and a closure as arguments. | |
notifCenter.requestAuthorization(options: [.alert, .sound, .badge]) { |
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
//The following line should already be present in your AppDelegate.swift file | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
//Here is the call! Add the next line! It is recommended to ensure the registration is placed on the main thread. | |
DispatchQueue.main.async { | |
self.registerForPushNotifications() | |
} | |
//This should already be here | |
return true |
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
func getNotificationSettingsThenRegister() { | |
UNUserNotificationCenter.current().getNotificationSettings { | |
//This closure definition gets access to push notification settings | |
settings in | |
//Here we check if the user authorized push notifications | |
//If the user refused push notification auth, then this will exit early | |
guard settings.authorizationStatus == .authorized else {return} | |
//We pop the registration code onto the main queue as recommended by Apple |
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
//This function is called when you successfully registered for remote notifs | |
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
//This is one way we can convert the device token data into a String. | |
//apns stands for Apple Push Notification Services | |
let apnsDeviceToken = deviceToken.map {String(format: "%02.2hhx", $0)}.joined() | |
print(apnsDeviceToken) | |
} |
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
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { | |
//This function will be called when your attempt to register fails some how. | |
} |
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 UIKit | |
import PPUIElementModules91 | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
print(weMadeIT) | |
print(weDidItAgain) | |
} |
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 Foundation | |
public var hello: String = "Holy moly we did it!" |
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
public final class Fonts { | |
static func podFont(name: String, size: CGFloat) -> UIFont { | |
//Why do extra work if its available. | |
if let font = UIFont(name: name, size: size) {return font} | |
let bundle = Bundle(for: Fonts.self) //get the current bundle | |
let url = bundle.url(forResource: name, withExtension: "ttf")! //get the bundle url | |
let data = NSData(contentsOf: url)! //get the font data | |
let provider = CGDataProvider(data: fontData)! //convert the data into a provider |
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
public final class Fonts { | |
static func podFont(name: String, size: CGFloat) -> UIFont { | |
//Why do extra work if its available. | |
if let font = UIFont(name: name, size: size) {return font} | |
let bundle = Bundle(for: Fonts.self) //get the current bundle | |
let url = bundle.url(forResource: name, withExtension: "ttf")! //get the bundle url | |
let data = NSData(contentsOf: url)! //get the font data | |
let provider = CGDataProvider(data: fontData)! //convert the data into a provider |
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
LM-SJN-21004935:consumer-blank-ios slydon$ git pull upstream develop --rebase | |
remote: Counting objects: 6388, done. | |
remote: Compressing objects: 100% (8/8), done. | |
remote: Total 6388 (delta 3638), reused 3639 (delta 3637), pack-reused 2743 | |
Receiving objects: 100% (6388/6388), 7.98 MiB | 4.46 MiB/s, done. | |
Resolving deltas: 100% (4828/4828), completed with 827 local objects. | |
From https://github.blank.com/IOS-R/consumer-blank-ios | |
* branch develop -> FETCH_HEAD | |
f7c8e8d86a..75b1fa983e develop -> upstream/develop | |
First, rewinding head to replay your work on top of it... |
OlderNewer