Xamarin Forms using FirebasePushNotificationPlugin plugin with Autofac and Shell unable to display UI elements nor redirects - xamarin

I'm experiencing an issue that I've tried different ways to resolve and have been unsuccessful with. Whenever receiving a message via CrossFirebasePushNotification.Current.OnNotificationReceived I get the payload and can read it, but I can't do anything "visual" in my app. In other words, I get the notification but when I want to either redirect to another page or even display a DisplayAlert message, nothing happens. MessagingCenter can be received, but any instructions within the procedure that have to do with redirecting or DisplayAlert (anything changing the UI it appears) will not be executed.
Looking for help in how to visually show in the app the user has received a message.
This is in MainShell.xaml.cs (I've also placed it in App.xaml.cs too):
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Received"); // this works
foreach (var data in p.Data)
{
System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}"); // this works
}
//TODO: Code to determine if user is signed in
if (true)
{
System.Diagnostics.Debug.WriteLine("Debug: Goto Registration page from MainShell"); // this works
//Task.Run(async () => await Shell.Current.GoToAsync("registration")); // this does not work (just ignores it and doesn't fire constructor)
//Task.Run(async () => await Current.DisplayAlert("Request Received", "A message is waiting...", "Ok")); // this does not work
MessagingCenter.Send(this, "RequestReceived"); // this works, the receiver will display debug info, but will not redirect nor display any UI messages or interact with the UI.
}
};
Thank you for any help or guidance,
Robert

Related

Hide Testcafe Overlay

I'm trying to use testcafe to fill forms on a page.
When the form is filled, I'd like to be able to stop the test with the window still open so a human can review the form before clicking submit.
I can pause the test with t.debug() but this locks the page and shows the testcafe controls overlay at the bottom.
Is there a way I can remove this overlay and unlock the page?
I've tried using client functions to hide the element with javascript as follows:
test('test_1', async (t) => {
const hideOverlay = ClientFunction(function() {
const target = document.querySelector('#root-hammerhead-shadow-ui > div > div');
target.style.display = 'none';
return true;
})
await t.wait(5000);
setTimeout(async function() {
const res = await hideOverlay();
console.log('-------->', { res });
}, 6000);
await t.debug();
});
Since no code will be executed after debug is invoked, I thought I could use a settimeout to queue the call to the function that hides the overlay, so that it is queued and only executes after debug is called and the overlay is visible.
Didn't work though :( code didn't execute, got an unhandled promise rejection.
Could really use some help here, thanks :)
Yes, you can unlock the page by clicking the 'Unlock page' button in the footer as #VysakhMohan mentioned in the comment.
Please refer to the client-side debugging documentation for more details.

How to get handle of popup window (WebdriverIO)

I am very very new to automated testing and I am currently completely stuck with the following issue:
I have a webpage open(first window)
In the same test I call a .newWindow(second window) and do some stuff in that window. The last action opens new popup window(popup window).
What I need, is to set the focus on a popup window.
According to WebdriverIO API I can use .switchTab http://webdriver.io/api/window/switchTab.html
But to be able to switch to a popup window I have to indicate handle, but I don't understand how to get the handle of a popup window :(
That s my piece of code:
//this is the part where I have already second window open
it('should open email letter', function(done) {
client
.pause(2000)
.clickAndWait('[title="Password restore"]', 4000)
.clickAndWait('[title="Restore password"]', 7000) //this is the part where popup window opens
.pause(2000)
.windowHandles(function(err,res){
console.log(res, handles)
}) // I have got three handles but i dont know how to use them now
.........
There is a lot of examples in java, but i didnt find anything that would fit mine language.
Please, excuse me my dumbness, I am really a very beginner and I will appreciate if somebody could explain that to me.
Thanks a lot in advance!
we not use getCurrentTabId to remember the handle of the currently open window?
For example:
var main, popup; //your window handles
client
.getCurrentTabId(function (err, handle) {
main = handle;
})
.newWindow('http://localhost:9001/') //you are on popup window
.getCurrentTabId(function (err, handle) {
popup = handle;
})
.switchTab(main) //you are back to main window
.switchTab(popup) //you are on popup again
.close(popup) //extra bonus!
I notice you stated "The last action opens new popup window(popup window). What I need, is to set the focus on a popup window."
I had this issue. But the new window was opened when clicking on login with facebook. This caused an issue on finding the handle for the new window because I could not use .newWindow('http://localhost:9001/'). The API keys and all sorts are added as parameters when using a social login. So one has little control
To handle this I registered each window ID as its opened.
The first background step in my feature is Given I open the url "/a.html"
In the step you can set an empty array as the variable windowID with let let windowID = []
So my step file would look like this
const url = 'http://localhost:8080'
let windowID = []
this.Given(/^I open the url "([^"]*)"$/, (path) => {
browser
.url(url + path)
console.log(`# Navigating to ${url + path}`)
expect(browser.getUrl()).toEqual(url + path)
windowID.main = browser.getTabIds()
});
During the step after clicking the Facebook button you can then check all the open window ID's and drop the one that matches windowID.main
this.When(/^I authenticate with facebook$/, function (arg1) {
// log the ID of the main window
console.log('Main Window ID' + windowID.main)
browser
.pause(2000)
.getTabIds().forEach(function (value) {
if (value === windowID.main) {
// we do not need to do anything with windowID.main as it's already set
return
}
// if the value does not match windowID.main then we know its the new facebook login window
windowID.facebook = value
})
// log both of these
console.log('Main Window ID: ' + windowID.main)
console.log('Facebook Window ID: ' + windowID.facebook)
// Do the login
browser
.switchTab(windowID.facebook)
.setValue('input[name="email"]', process.env.FACEBOOK_EMAIL)
.setValue('input[name="pass"]', process.env.FACEBOOK_PASSWORD)
.submitForm('form')
});
note that I add credentials as an environment variable. This is a good idea, you don't want to commit your personal credentials to the code base. One may think well obviously, but you may not, who knows.
You had your question answered years ago, but I found this post first when trying to find a solution so it seems a sensible place to put this addition.

How can I dynamically change kendo.mobile.Application's loading property?

I am developing a mobile web app using Kendo UI Mobile. Whenever we make any AJAX calls, or our DataSources make them we call app.startLoading() to show the loading icon to the user. This works very well.
However, depending on the context in which the call is made we would like to change the text that is displayed along with the loading icon. I know you can define this when I create the kendo.mobile.Application instance. How can I change it afterwards?
The documentation does not suggest a way to do this, and a browse of the source code did not help me either. Is this really not possible?
EDIT: This is using Kendo UI Mobile v.2012.3.1114
I usually make a "utility" function to do this:
var _kendoApp = new kendo.mobile.Application(document.body, {});
var showLoading = function (message) {
_kendoApp.loading = "<h1>" + (message ? message : "Loading...") + "</h1>";
_kendoApp.showLoading();
};
I am also setting a default message of "Loading..." if one isn't passed in.
Edit:
I could have sworn that worked for me in a past app I did, but judging by thr source, I think you are right, my answer above shouldn't work. My best suggestion is to add a class to the message element so you can target it, and use jQuery to change the text.
var _kendoApp;
var showLoading = function (message) {
$(".loading-message").text(message ? message : "Loading...");
_kendoApp.showLoading();
};
_kendoApp = new kendo.mobile.Application(document.body, {
loading: '<h1 class="loading-message">Loading...</h1>'
});

Dojo: Dialog refreshing a dojox.layout.ContentPane in a TabContainer

I have a problem with Dojo in Internet explorer 7/8 (this works fine in Firefox).
Basically I have a tab container with a number of tabs in it (these are dojox.layout.ContentPane's). On one of these tabs I want to have a "comments box" which would popup a dialog and ask the user to put something in. The comment is then saved by an call to the back end and I want the tab to reload to show the new comment.
The logic of my save button works something like this:
<button data-dojo-type="dijit.form.Button" type="button" data-dojo-props="iconClass:'dijitIcon dijitIconSave', showLabel: true" title="Add your comment">Add Comment
<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
require(["dojo/dom"], function(dom)
{
var tText = dijit.byId('comment_70').get('value');
if (tText == '')
{
alert('You have not entered any comment');
return;
}
var tJSONRPC = new JSONRpcClient('JSON-RPC');
try
{
tJSONRPC.be.addComment('70', tText);
var tTab = dijit.byId('Detail_70');
tTab.refresh();
}
catch (Ex)
{
alert(Ex);
}
});
</script></button>
Does not appear to be terrible taxing (the 70 at the end is the ID so that the user can have more than one of these open at the same time, hence the tabs).
As mentioned this works fine in Firefox but not in IE 8/7, it throws an error in some of the generated code within dojo (_32.focus(); to be precise), the error message I get in the debug console is "Unexpected call to method or property access"
Try this, with your line tTab.refresh();:
setTimeout(function() { tTab.refresh(); }, 0); // whenIdle
Its nearly impossible to tell where the thrown exception comes from - you should use the developement dojo-1.M.m-src/dojo/dojo.js code so optimized function- and variable-names are expanded (along with useful commenting once you step-through-debug).
Reason for the above is to eliminate, that exception occurs while handling button onclick-focus event (refresh will tear down DOM in the tab - along with your button)

Back button not updating hash in iframe on IE

I have an application that uses a combination of the onhashchange event (for new browsers) and the hashchange plugin by Ben Alman (for old browsers) to track the history while making ajax calls or actions. Works like a charm in all browsers, back and forward buttons let the user navigate the actions that get recorded by changing the hash. So far so good. Now our page will be hosted in an iframe on a clients page in a diff domain(cross domain). Chrome kind of works but if you put to many changes in the history it stops working at some point (we can live with that). IE dosen't work at all. When I navigate our application by clicking on links and updating the hash new history items get created in the parent page but when I hit the back button the hash in the nested page is not updated therefore the hashchange event never fires. Anyone solved this problem before? Many thanks
Initialize the hash change event handling
if ("onhashchange" in window && !($j.browser.msie && $j.browser.version == '7.0')) {
window.onhashchange = function() {
var params = parseHash(location.hash)
if (params.tabId) {
if (getSelectedTabId() == params.tabId) return;
reloadPage(params.tabId);
}
};
}
else {// Plugin for older browsers
$j(window).bind('hashchange', function() {
var params = parseHash(location.hash)
if (params.tabId) {
if (getSelectedTabId() == params.tabId) return;
reloadPage(params.tabId);
}
});
}

Resources