This file contains hidden or 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
// currentVC => FirstViewController | |
guard let pvc = self.presentingViewController else { return } | |
self.dismiss(animated: true) { | |
pvc.present(SecondViewController(), animated: true, completion: nil) | |
} |
This file contains hidden or 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
// currentVC => FirstViewController | |
self.dismiss(animated: true) { | |
self.present(SecondViewController(), animated: true, completion: nil) | |
} |
This file contains hidden or 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
let phoneNumber = "01012345678" | |
var firstIndex = phoneNumber.index(phoneNumber.startIndex, offsetBy: 0) | |
var lastIndex = phoneNumber.index(phoneNumber.startIndex, offsetBy: 3) | |
let mobCom = "\(phoneNumber[firstIndex..<lastIndex])" | |
firstIndex = phoneNumber.index(phoneNumber.startIndex, offsetBy: 3) | |
lastIndex = phoneNumber.index(phoneNumber.endIndex, offsetBy: -4) | |
let mobNo1 = "\(phoneNumber[firstIndex..<lastIndex])" |
This file contains hidden or 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
extension AppDelegate: MessagingDelegate { | |
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) { | |
let dataDict: [String: String] = ["token": fcmToken] | |
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict) | |
} | |
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) { | |
print("[Log] didReceive :", messaging) | |
} |
This file contains hidden or 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
extension AppDelegate: UNUserNotificationCenterDelegate { | |
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | |
completionHandler([.alert, .badge, .sound]) | |
} | |
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | |
completionHandler() | |
} | |
} |
This file contains hidden or 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, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) | |
print("[Log] deviceToken :", deviceTokenString) | |
Messaging.messaging().apnsToken = deviceToken | |
} |
This file contains hidden or 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, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
FirebaseApp.configure() | |
Messaging.messaging().delegate = self | |
UNUserNotificationCenter.current().delegate = self | |
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] | |
UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { _, _ in } | |
application.registerForRemoteNotifications() |
This file contains hidden or 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
let appleIDProvider = ASAuthorizationAppleIDProvider() | |
appleIDProvider.getCredentialState(forUserID: userIdentifier) { (credentialState, error) in | |
switch credentialState { | |
case .authorized: | |
// The Apple ID credential is valid. Show Home UI Here | |
break | |
case .revoked: | |
// The Apple ID credential is revoked. Show SignIn UI Here. | |
break | |
case .notFound: |
This file contains hidden or 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
extension ViewController: ASAuthorizationControllerDelegate { | |
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { | |
if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential { | |
// Create an account in your system. | |
let userIdentifier = appleIDCredential.user | |
let userFirstName = appleIDCredential.fullName?.givenName | |
let userLastName = appleIDCredential.fullName?.familyName | |
let userEmail = appleIDCredential.email | |
//Navigate to other view controller |
This file contains hidden or 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 performExistingAccountSetupFlows() { | |
// Prepare requests for both Apple ID and password providers. | |
let requests = [ASAuthorizationAppleIDProvider().createRequest(), | |
ASAuthorizationPasswordProvider().createRequest()] | |
// Create an authorization controller with the given requests. | |
let authorizationController = ASAuthorizationController(authorizationRequests: requests) | |
authorizationController.delegate = self | |
authorizationController.presentationContextProvider = self | |
authorizationController.performRequests() |