Posts

Post not yet marked as solved
0 Replies
1k Views
I want to add a category to my push notification and I can't seem to get any success in my attempts. I tried StackOverflow, but nobody responded, so I'm trying here. I thought it would be an issue with my Firebase Cloud Functions message payload, but it's not. I have a function to set a category on my notification when interacted with: func configureCategory() {     let viewAction = UNNotificationAction(identifier: "viewNewEvent", title: "View New Event", options: UNNotificationActionOptions.foreground)     let viewCategory = UNNotificationCategory(identifier: "newEventCategory", actions: [viewAction], intentIdentifiers: [], options: [])     UNUserNotificationCenter.current().setNotificationCategories(Set([viewCategory]))   } I then call this right before application.registerForRemoteNotifications() From, reading many articles, I thought this would work, but my notification just ends up with no actions when i receive it and interact with it. I even decided to create a UNNotificationServiceExtension, and add the identifier in that, but that didn't work either.  override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) - Void) {     self.contentHandler = contentHandler     bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)           if let bestAttemptContent = bestAttemptContent {              bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"       bestAttemptContent.categoryIdentifier = "newEventCategory"               contentHandler(bestAttemptContent)     }   } If anybody knows how to do this properly and sees I'm missing something or placing something in the wrong spot, please point it out and let me know, thanks.
Posted Last updated
.
Post not yet marked as solved
14 Replies
1.1k Views
I'm having an issue when it comes to instantiating a view controller and actually having it stay on the screen without automatically jumping to the next view controller. I setup a view controller sort of identical to another view controller I have in my project, but the class names are completely different obviously. Now I want to instantiate this view controller when a user finishes signing up. So I do that in this block of code: {       //Create user       Auth.auth().createUser(withEmail: schoolEmail, password: schoolPassword) { (result, error) in                   guard error == nil else {           self.showAlert(title: "Error Signing Up", message: "There was an error creating the user, please check your connection and try again later.")           return         }           let db = Firestore.firestore()           guard let result = result else { return }           db.document("school_users/\(result.user.uid)").setData(["school_name":schoolName,                                        "school_id":schoolID,                                        "remindersPushNotificationsOn": true,                                        "updatesPushNotificationsOn": true,                                        "schoolDistrict":schoolDistrict,                                        "time_created":dateCreated,                                        "userID": result.user.uid],                                        merge: true) { (error) in             guard error == nil else {               self.showAlert(title: "Error Signing Up", message: "There was an error creating the user, please check your connection and try again later.")               return             }           }                       let changeRequest = result.user.createProfileChangeRequest()           changeRequest.displayName = schoolName           changeRequest.commitChanges { (error) in             guard error == nil else {               return             }             print("School Name Saved!")           }                             }       guard let nextVC = storyboard?.instantiateViewController(withIdentifier: Constants.StoryboardIDs.SchoolOnboarding) as? SchoolSignUpOnboardingViewController else { return }       navigationController?.pushViewController(nextVC, animated: true)     } This works, but to an extent. When I finish signing up, the view controller is displayed for literally a split second with the proper UI and everything and it then automatically segues to the next view controller which makes no sense. This has never happened to me with segues before and I can't understand why it's happening now. I used TestFlight with my friends last night and for some reason bits of my code just completely turned it's back on me when I was trying to test certain functionalities. I wanted to also add a new addition which was this view controller I want to instantiate but now this addition to the app won't even work properly. So with this in mind, I was wondering if it's an issue with the TestFlight and the app's build number, so I incremented the build number and tried to run the app on the simulator again, but it still didn't keep the view controller on the screen and just kept jumping to the next view controller automatically. This is so frustrating because I genuinely can't figure out what the cause of this view controller issue is. Any suggestions?
Posted Last updated
.
Post not yet marked as solved
2 Replies
648 Views
I am trying to do a data transfer to CheckoutViewController that was coded programmatically. Before I connected the CheckoutViewController to storyboards, the view was loading perfectly fine and my initializers weren't causing any issues. This is the block of code I had in the CheckoutVC.  let paymentContext: STPPaymentContext   let config: STPPaymentConfiguration       let customerContext = STPCustomerContext(keyProvider: MyAPIClient())              init() {     let config = STPPaymentConfiguration()     let paymentContext = STPPaymentContext(customerContext: customerContext, configuration: config, theme: .defaultTheme)     config.requiredBillingAddressFields = .name     self.paymentContext = paymentContext     self.config = config     super.init(nibName: nil, bundle: nil)     self.paymentContext.delegate = self     self.paymentContext.hostViewController = self   }       required init?(coder: NSCoder) {     fatalError("init(coder:) has not been implemented")   }     Now when I try to load the vc after setting it up in storyboard, it crashes with a fatal error, how can I fix this?
Posted Last updated
.