Ionic content not updating after callback from external plugin - callback

As part of the functionality of the app we are developing, when an android alarm is fired, a dialog box is to appear with an "Accept" or "Reject" button. Selecting reject does nothing, but selecting "Accept" triggers a callback from the plugin, which I have passed a function into. This function causes the ionic app to navigate to the root page of the app.
The issue I am having is, when I then navigate to another page after that where the user selects a value, and this value is displayed back to them and a button is enabled, the value display is not updating, and the button is not becoming enabled. Nothing seems to be updating.
What I have found is that pressing the back button on my android device will cause the page to update, which is not ideal.
This functionality works without the callback from the plugin.
What is happening here? And how do I fix it?
Passing the function into the plugin.
alarms_plugin.onAlarmRecieved = (alarmId) =>{
this.events.publish('alarmRecieved', alarmId);
}
Plugin-side functions
alarmRecieved: function(alarmId){
alarms_plugin.onAlarmRecieved(alarmId);
}
onAlarmRecieved: null
Navigating to root page on alarmRecieved
this.events.subscribe('alarmRecieved', (alarmId) =>{
if(alarmId != 'TIMEOUT')
this.nav.setRoot(HomePage);
});

Fix found by surrounding the this.nav.setRoot(HomePage) in this.zone.run(..).
Supposedly calling navigation within a subscription event causes issues like I was having.

Related

Ionic sidemenu not working after login, goes back to the login page instead

I have a login page where I disable the sidemenu with:
ionViewWillEnter() {
this.menuCtrl.enable(false);
}
ionViewDidLeave() {
this.menuCtrl.enable(true);
}
After logging in, I navigate to / which goes to /welcome:
this.router.navigate(['/']);
In /welcome, I have the menu turned on:
ionViewWillEnter() {
this.menuCtrl.enable(true);
}
Using Edge/Chrome, when I try to use the side-menu after logging in, it instead tries to "Go Back" to the login page:
Added: If I refresh the page after on /welcome, it reloads the page and fixes the sidemenu. So whatever is happening it seems like it must be left over from the login screen's functionality. Also, I thought adding ion-header fixed it, worked for about 2 logins then suddenly went back to it's previous behavior.
I've also noticed that if I sign out, the Angular authguard sends it back to /login, but if I try to swipe while on the login page, it tries to take me back to the app as though I was authenticated.. Then when I click on a link the Auth guard does it's job and sends be back to login again.
This time, I can still swipe left but a blank page tries to appear from the left instead - and this happens in desktop mode too.
Can anyone help me with this please?
I thought adding ion-header fixed it, it did at first, then suddenly started doing it again.
I finally ended up disabling Swipe within Ionic with:
IonicModule.forRoot({ swipeBackEnabled: false})
If anyone has any info it'd be appreciated.

Flutter mobile app, clicking an existing and valid physical back button is not working, even though the Cucumber step succeeds

I am using JDK 1.8_202, appium 2.0.0-beta.46, node v18.12.0
There is a programmer developed back button (<--) whose className as "android.widget.Button" whose className as "android.widget.Button", but when I try to verify it using search option, I am getting this pop up.
Programmatically nothing is happening, even though as a CucumberBDD step, it is showing as executed.
I am executing on locally connected physical device 'Samsung galaxy note 8'
Why back button tap/click action is not working even when it is executed??
I open my flutter mobile app. I am at landing page
Do some navigation forward. Comeback to a dashboard page
From dashboard page to get back to landing page, there is a back button like (<--), which I manual tap and can get back to landing page, with no problem.
Programmatically nothing is happening, even though as a CucumberBDD step, it is showing as executed.
From Appium Inspector I see it's className as "android.widget.Button", but when I try to verify it using search option, I am getting this pop up.
The same button with the same click() method is working fine in another scenario.
I am using JDK 1.8_202, appium 2.0.0-beta.46, node v18.12.0
Does the previous navigation affects the functioning of the button click() action ? It should not be logically.
Why back button tap/click action is not working even when it is executed??

Enable browser action for an event in Google chrome

I am writing a chrome extension for capturing the URL. This is the code for my js file.
chrome.tabs.getSelected(null, function(tab) {
myFunction(tab.url);
});
function myFunction(tablink) {
alert(tablink);
}
Now i can get the URL alert for the page by explicitly clicking on the browser action. I need it to popup the alert whenever i click on any tab in my browser.
Could you please let me know how to proceed with this?
PS: I am sure i have to use some kind of event listener.
chrome.tabs.getSelected is deprecated since Chrome 33. Use chrome.tabs.query instead if needed.
Base on your need to make popup the alert whenever you click on any tab in your browser. You can use chrome.tabs.onActivated.addListener.
The code I created is as below and it works with me. It popup the alert of current page's url whenever you click on any tab in your browser.
chrome.tabs.onActivated.addListener(function(activeInfo) {
//alert("popup");
chrome.tabs.get(activeInfo.tabId, function(tab){
alert(tab.url);
});
});
Also keep in mind to add "permissions": ["tabs"], in your manifest file since it requires access to the url. See here:https://developer.chrome.com/extensions/tabs

lift disabling back button actions

I'm creating a transaction related site using lift. In here, there's a requirement to show a success page after the user action.
when i make action happen and press the browser's back button. it again goes to the previous page(before transaction page) making the transaction doable again. I need to limit this behavior. Is there any way of limiting the access to previous page by browser back button in lift.
There is no way to reliably stop the user from returning to the URL, but you can stop them from invoking the action more than once. Take a look at S.oneShot. From the Scala Doc:
All functions created inside the oneShot scope will only be called
once and their results will be cached and served again if the same
function is invoked
If you wrap the function that occurs when the button is pressed, even if the user does return to the page and click the button a second time, the body of the function shouldn't be invoked again.

JavaScript: How to force a page reload on reset?

I have a page with some generated HTML that survives the form's reset button. It is a problem because that HTML is inconsistent with the values in the cached default form.
In principle I guess it could be solved easily if I could force a hard reload from the server when the user presses the reset. However I see that the Chrome browser does not support the onReset event (in fact it is deprecated in HTML5).
But perhaps I could work around the missing onReload event. Can I re-define what happens when the reset button is pressed? In my case the apply and reset buttons are located in general HTML templates which I cannot change. Can I attach a function to the button from JavaScript?
You can replace the "reset" button , by a regular button.
And use the "onClick" event, to trigger a page reload.
EDIT
oops I missed the template part,
You can add a function to a button from Javascript.
First you need to "get" the button, with something like document.getElementbyId('resetButton');
If the button doesn't have a ID, you still can to retrieve it by doing javascript dom traversal
then you can add a function like :
var resetButton = document.getElementbyId('resetButton');
resetButton.onclick= reloadPage;
function reloadPage(){
window.location.reload();
}