Xamarin.Forms Shell - Cold Start App Opening - xamarin.forms

I have a Xamarin.Forms App (v4.3.0.908675) that looks like this:
It has several tabs and uses a very basic XF Shell for the layout.
It receives several Push Notifications and in one of them the App needs to open a specific tab after the Notification is tapped. The App then it's cold started.
I'm trying the following in order to do that: In my App.xaml.cs I have a method that is called every time a notification is opened that sends a message to the shell in order to select the tab.
public App()
{
// One Signal
OneSignal.Current.StartInit( "8449c-..." )
.HandleNotificationOpened(HandleNotificationOpened)
.EndInit();
}
// When a push notification is opened
private void HandleNotificationOpened( OSNotificationOpenedResult result )
{
Messenger.Default.Send( new ServiceScheduleMessage(), "LoadSectionDeepLink" );
}
Then in my AppShell.xaml.cs I receive the message and change the default tab:
//* loading service schedules deep link
private void LoadServiceSchedulesDeepLink()
{
CurrentItem = this.my_service_schedules;
}
However, when I do that the App opens like this:
The tabs are gone, and if tap on some of the buttons that navigate to other pages, the App crashes. It seems like I changed the tab before the Shell was ready and caused this weird behavior.
Question:
Is there a way to know that the App has finished started so I can call some other method like change the current Shell Tab?

Related

Firebase in app messaging on action button click how to open new activity

I am trying Model layout of Firebase in-app messaging. On model I have added one button. and for that button action, I have provided the firebase dynamic link. So when the user is clicking on button dynamic link is getting a trigger. and it's first opening the browser and after that, it's again coming to application. This interaction is not looking more natural. I want to open the new page on click of the action button. But on click of action button first browser is getting open. How to solve this issue?
You can implement FirebaseInAppMessagingClickListener in your mainActivity and initialize in onCreate() method using FirebaseInAppMessaging.getInstance().addClickListener(MainActivity.this);
for more details please click below link-
https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android
Simplest way to achieve this would be to extend your MainActivity with FirebaseInAppMessagingClickListener if you know that the In-App Message will be triggered there & then create & Intent & open another activity.
Add the messageClicked function to your class:
#Override
public void messageClicked(InAppMessage inAppMessage, Action action) {
// Determine which URL the user clicked
String url = action.getActionUrl();
// Get general information about the campaign
CampaignMetadata metadata = inAppMessage.getCampaignMetadata();
// Trigger an Intent to another class
}
And register it (in your MainActivity) too:
FirebaseInAppMessaging.getInstance().addClickListener(this);
PS: In the case that you schedule your In-App Message to be triggered on a certain event, implement this code in the activity there.

Custom URL issue in flex ios app

i am using custom url scheme in my flex iOS app and it’s working fine when i start my app from a web link..but the issue is when i start my app from start menu in iPad and move to webpage in safari.In page i click a button that redirects it to my app, at that time app call “preinitialize” method more than once..it wary every time, some time it’s 2,3,4 and different one each time..i don't know why it’s behaving like this..can i know the reason please its urgent..
thanks…any help will be appreciated.
Create a flag initialized and set it to true when preinitialize is called. All other calls to this method can be filtered out. Simple example:
private var initialized:Boolean = false;
public function preinitialize():void
{
if (initialized) return;
initialized = true;
}
Next step would be finding the real cause of the multiple calls, but for that we would need to see some code of your app.

Main application window and a dialog interaction in Qt

Good day!
Have a problem: main window (MyApp for example) works in background (behind all other windows or in tray), not necessary to show it without need. After some period of time some reminding StayOnTop dialog appears (having parent = 0, to be not tied to main window) and asks for some user interactions. After dialog closes I’d like to keep an application window user currently working with active, and user continue do his job not switching to MyApp. However, instead of above behaviour, main MyApp window appears and user forces to switch back to his window (job) – inconvenient.
How to prevent MyApp main window appearing after closing the dialog? Need to install some event filter or access OS API? Problem exists in Mac, Windows, Linux.
You could try to re-implement the main window's showEvent and ignore that event, in case other windows are visible.
void main_window::showEvent( QShowEvent* e )
{
if( /*one or more of its children are visible */ )
{
// nothing to do
}
else
{
QMainWindow::showEvent( e );
}
}
Maybe just try invoking hide method after dialog call? Other possibility - try setting this:
http://doc.qt.io/qt-4.8/qwidget.html#windowFlags-prop to Qt::Popup.

How to avoid the display of multiple alert windows in Flex

I have a timer in my application. For every 30 min, it will hit the web services and fetch the data and updates the UI. The application was working fine till yesterday. Suddenly, because of some issue, the web services were not available for some time. During that period, Application displayed the RPC Error multiple times(More than 100 alert boxes) in alert window. Because of this alert boxes, my application was hanged and i was not able to do anything.
I have tried several approaches, but nothing worked.Finally, I have tried to use a flag. In all the approaches, this looked promising. so i have implemented it.Basically, in this approach whenever we open an alert we will set a flag.While opening and closing alert we will reset this flag. But it didn't work as expected. Is there any approach, which can help us in avoiding multiple alert windows.
Please help me, to fix this issue.
I would write wrapper for opening alerts, and use only this wrapper, not Alert.show in the code:
public class AlertWrapper {
private static var lastAlert:Alert;
public static function showAlert(text:String, title:String):void {
if (lastAlert) {
PopUpManager.removePopUp(lastAlert);
//or
//return; //ignore last alert
}
lastAlert = Alert.show(text, title, null, 4, onAlertClose);
}
private static function onAlertClose(event:CloseEvent):void {
lastAlert = null;
}
}
Imports are missing, but I hope the idea is clear.

What is the correct way to open and close window/dialog?

I'm trying to develop a new program. The work flow looks like this:
Login --> Dashboard (Window with menus) --> Module 1
--> Module 2
--> Module 3
--> Module XXX
So, to open Dashboard from Login (a Dialog), I use
Dashboard *d = new Dashboard();
d->show();
close();
In Dashboard, I use these codes to reopen the Login if the user closes the Window (by clicking the 'X')
closeEvent(QCloseEvent *)
{
Login *login = new Login();
login->show();
}
With a Task Manager opened, I ran the program and monitor the memory usage. After clicking open Dashboard from Login and closing Dashboard to return to Login, I noticed that the memory keeps increasing about 500 KB. It can goes up to 20 MB from 12 MB of memory usage by just opening and closing the window/dialog.
So, what did I do wrong here ? I need to know it before I continue developing those modules which will definitely eat more memory with my programming. Thanks in advance.
One reason might be you are creating the Login widget again and again without deleting it.
I believe your Login is a QWidget, Dashboard is a QDialog. Instead of close(), just hide the Login widget by hide() or setvisible(false).
In the closeEvent() of the DashBoard give
done(someIntValue);
While accessing DashBoard, instead of show() give
int returnValue = d->exec();
if the returnValue is someIntValue, show() the Login Widget.
This way you are avoiding the creation of the Login widget multiple times. But a lot other factors might be responsible for your memory usage, which could be found out only by going through the entire code.
Edit:
Since your Dashboard is a QMainWindow you can't call done(someIntValue); Instead try connecting the destroyed( QObject * obj = 0 ) signal of the DashBoard and in the corresponding slot show() your Login.. Of course you should have the instance of the DashBoard in the Login Dialog and the connection between the above signal and slot should be made in the Login.
Hope it helps.

Resources