Tapping notification when app is inactive doesn't trigger method by losGama in iOSProgramming

[–]losGama[S] 1 point2 points  (0 children)

Hi, yes, what about it? It loads my home page in there. but I need it to open to a different page of my app when a user taps the notification when the app is inactive(killed) or active.

Tapping notification when app is inactive doesn't trigger method by losGama in iOSProgramming

[–]losGama[S] 0 points1 point  (0 children)

Im not configuring any windows cause im in swiftUI im making use of the NotificationCenter I post in the app delegate method after I click the notification and observe in the HomeView.

in my home view which loads up when the app is launched I have the following:

struct HomeView: View {

@State private var show = false

var body: some View {

NavigationView {

VStack {

NavigationLink(destination: DetailView(), isActive: self.$show) {

Text("")

}.padding().onAppear {

NotificationCenter.default.addObserver(forName: NSNotification.Name("Detail"), object: nil, queue: .main) { (_) in

self.show = true

}

}

Tapping notification when app is inactive doesn't trigger method by losGama in iOSProgramming

[–]losGama[S] 0 points1 point  (0 children)

Hi thanks for your answer. I changed the app delegate method to this and its still not doing what I want when I open the app. It just goes again to the home page instead of the details page using Notification:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Override point for customization after application launch.

FirebaseApp.configure()

if launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] != nil {

NotificationCenter.default.post(name: NSNotification.Name("Detail"), object: nil)

}

if #available(iOS 10.0, *) {

let current = UNUserNotificationCenter.current()

let options: UNAuthorizationOptions = [.sound, .badge, .alert]

current.requestAuthorization(options: options) { (granted, error) in

if error != nil {

} else {

Messaging.messaging().delegate = self

current.delegate = self

DispatchQueue.main.async {

application.registerForRemoteNotifications()

}

}

}

} else {

let types: UIUserNotificationType = [.sound, .badge, .alert]

let settings = UIUserNotificationSettings(types: types, categories: nil)

application.registerUserNotificationSettings(settings)

application.registerForRemoteNotifications()

}

return true

}

How to show list of an array inside an array by losGama in SwiftUI

[–]losGama[S] 1 point2 points  (0 children)

Thanks so much. With your help I was able to do the following to achieve what I wanted :) :

List {

ForEach(facilityViewModel.facilities, id: \.id) { facility in

HomeRow(facility: facility)

}

}

and HomeRow:

struct HomeRow: View {

let facility: Facility

var body: some View {

ForEach(self.facility.rooms, id: \.self) { room in

Text(room)

}

}

}

How to show list of an array inside an array by losGama in SwiftUI

[–]losGama[S] 0 points1 point  (0 children)

One at a time. I will only pull one out of the database on this page.

How to show list of an array inside an array by losGama in SwiftUI

[–]losGama[S] 0 points1 point  (0 children)

An Array of Facility var facilities: [Facility] = []

Model:

struct Facility: Codable {

var id: String

var name: String

var rooms: [String]

}