can't click home bottom navigation when using explicit deep link (navigation component) - kotlin

I'm making a scheduler app that receive notification.
I tries to make an action for notification, when it clicks it will go to my schedule page.
I use navigation component to make this app, and the problem occur when i try to explicit deep-link to schedule page.
when i want to click home buttom navigation bar, i can't go to that place like it's not gonna happen.
but, when i click back button from schedule page, it'll navigate to home, and from that i was be able to click home button.
i think it's because the start destination change from home to schedule page, but im not sure.
here's my code:
val pendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.main_navgraph)
.setDestination(R.id.action_schedule)
.createPendingIntent()
val builder = NotificationCompat.Builder(context, SCHEDULE_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle(title)
.setContentText(dateTime)
.setSound(soundUri)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
I appreciate all the help!

Related

How do I use AbortController when the user clicks a button and then navigates away?

I'm fairly new to AbortController and so far I've only used it in useEffect callbacks. However, I have a screen in my React Native app which allows the user to click a button to open a dialog; in the background the button click causes an axios call to the api, and then the retrieved information is shown in the dialog.
But what happens if the user clicks the button and then quickly navigates away? In this case, the information doesn't need to be retrieved, and it can't be displayed once it's been retrieved anyway.
Is there a way to handle this? ie can I set up an AbortController and then if the user navigates away from the screen, abort the signal so that the api call gets cancelled?
I don't know If I understand you correctly, but you can use useEffect cleanup function to cancel axios request. About cleanup function: https://dev.to/otamnitram/react-useeffect-cleanup-how-and-when-to-use-it-2hbm.
If you want you can prevent user to go back, until axios fetching is done-> https://reactnavigation.org/docs/preventing-going-back/

i have one component which is present in all other components , and i want to go back to previous page from where i came from, what is the way?

Notification component
which is present in the Home component, History Order Component, Profile Component,
when I clicked the notification icon, from the home page, I go to the notification page,
presuppose I clicked the notification icon from the profile page, and go to the notification page, but when I navigate to go back, I am going to the home page, instead of going back to the profile page

Vue router how to trigger navigation guards before entering external domain

I have a Vue application and need to know when a user is about to navigate out of my application.
I have a beforeRouteLeave in place that triggers an alert if I go from myvueapp.nl/example to myvueapp.nl/example2 however if I navigate from myvueapp.nl/example to www.google.nl it doesn't trigger.
The reason I need to do this is the following:
You can navigate to /example/123 and this will open the example page and open a modal showing the user data of person 123. when you close this modal a router.go(-1) will be triggered. This allows me to use nested modal views. However if you go from google.com directly to /example/123 and then close the modal you will be send back to google.com. My idea was to check where a user is about to navigate to and if it is outside my domain I will check if the modal is open. is the modal open then close that instead of navigation. If it was already closed then let the user go on their way.
How can I know when a user is about to navigate out of my application?

back doesn't work properly when navigating from notification in closed app

When I navigate from a notification in closed app i'm able to navigate to the required screen.
The app navigates to dashboard when i click on the hardware back button, but when i go back from a custom back button in toolbar header it navigates to the dashboard(as required) but instantly comes back to the same page.
Navigating from a notification:
this.props.navigation.push("screen", {
data: somedata,
})
Navigating back to dashboard:
this.props.navigation.push('Dashboard')
I also tried using ResetAction function but it had the same results.
How to solve this?
This is due to , your screen is not stack that time, for that You have firstly push that screen to stack and navigate it.
And without any operation of notification click , its default open the app first screen.
You should use this code when you press on notification tray.
this.props.navigation.navigate('XYZScreen'{itemID:id,fromWhere:"NOTIFICATION"})
this line navigate you to XYZScreen with this keys params. and there you can identify that you are coming from NOTIFICATION . so according this you can come back the any screen.
Please use this code , it helps me.
because you don't have any screen in stack
please use replace function like
this.props.navigation.replace('Dashboard')
and for hardware back press use backHander and same code in that listener function

How can I remove pages from a Frame's history?

How can I manipulate a Frame's history in a WinRT XAML app?
The user will start on my hub page, where they can select an existing project to go to its edit screen, or they can select "new project". "New project" will take them through a short wizard, then take them to the "edit project" screen.
It makes sense for the wizard pages to just be pages that I navigate to in the frame; that way the user can back out of the wizard if they change their mind. (It'll only be two pages, so "back" can take the place of "cancel".) But once the wizard is done and the changes are committed, there's no longer any reason for those wizard pages to be in the history; if the user clicks Back from the "edit project" page, I want them to go right back to the hub.
To illustrate, I want the flow to look something like this:
Frame history: Hub. User clicks "New Project".
Frame history: Hub -> Wizard Page 1. User clicks "Next".
Frame history: Hub -> Wizard Page 1 -> Wizard Page 2. User clicks "Finish".
Frame history: Hub -> Edit Project.
Frame doesn't seem to have any methods along the lines of "remove from history". The docs do have hints that there might be some way to override the history, because the docs for GoBack say "Navigates to the most recent item in back navigation history, if a Frame manages its own navigation history" (emphasis mine), but that's all it has to say on the topic -- there's no mention of how someone else can manage history for it. So I don't know whether that's useful or not.
How can I remove my wizard pages from my Frame's history once the user completes the wizard?
You can remove pages from the history by calling SetNavigationState(string navigationState) on the frame. Unfortunately the format of the serialized navigationState is "for internal use only", so just changing the string might break your code in future versions.
I only can think of a future proof method to completely clear the navigation stack:
At program startup save the empty navigation state by calling GetNavigationState.
BEFORE calling Navigate for your Edit Project page, call SetNavigationState with the empty navigation state.
Your Edit Project page will now be the first page on the stack.
Starting with Windows 8.1, you have access to the BackStack property of a Frame. You can easily remove some content or clear the whole back stack.
Here is what I'm using the clear the back stack :
var rootFrame = (Window.Current.Content as Frame);
rootFrame.Navigate(typeof(MyPage));
rootFrame.BackStack.Clear();
its a solution for me :
while (ContentFrame.BackStack.Count > 1)
{
ContentFrame.BackStack.Remove(ContentFrame.BackStack.ElementAt(ContentFrame.BackStack.Count-1));
}