Dismissing the view controller in iOS mono touch - uinavigationcontroller

I created a button if i do click event the view must be dismissed and show the previous view. I used the below code:
partial void canceldata (NSObject sender)
{
Console.WriteLine("canceldata");
//NavigationController.PopToViewController(settrls,true);
this.NavigationController.PopViewControllerAnimated(true);
}
But this code is not working. Anybody suggest me how to dismiss the current view by clicking a button in iOS mono touch example.

It depends on how you open that controller. If it is pushed to the stack, then PopViewControllerAnimated() should be working. If it is presented as a modal dialog for example by
NavigationController.PresentViewController(new UINavigationController(new MyDialog()), true, null);
then you should call
NavigationController.DismissViewController(true, null);
instead.

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.

A-frame automatically entering in full screen mode oculus go

I am using A-frame for building a VR website. I wish to enter vr-mode without having to press the 'enter-vr' glasses on the oculus go more than once. For my application most of the html (including the a-scene) get reloaded (but the header/footer remain in place). For pc browsers this code works:
HTML:
<a-scene id="eqvrscene">
</a-scene>
<button id="enterVRButton" onclick="$('#eqvrscene')[0].enterVR();"> Enter VR </button>
JS:
$("#enterVRButton")[0].click();
but this does unfortunately nothing on the oculus go. Does anyone have a suggesting how to tackle this problem?
This may or may not be related, but you have a typo in your <a-scene> tag.
It's difficult to tell from your code, but are you sure your scene is loaded when you click the button?
Try first listening for the loaded event of the scene, and then setting up a listener for the button:
// Scene entity element
var scene = document.querySelector('a-scene');
// Button element
var enterVRButton = document.querySelector('#enterVRButton');
// Check if scene has loaded, otherwise set up listener for when it does.
if (scene.hasLoaded) {
addButtonListener();
} else {
scene.addEventListener('loaded', addButtonListener);
}
// Add our button click listener.
function addButtonListener() {
enterVRButton.addEventListener('click', function() {
scene.enterVR();
});
}
In A-Frame master branch, there is an API in place for adding a custom button for entering VR, so it may be released in 0.9.0. See the master docs: https://aframe.io/docs/master/components/vr-mode-ui.html#specifying-a-custom-enter-vr-button
If you're trying to automate the click event, I don't believe this will work in many browsers, as a user interaction is required for enterVR().
It’s not posible. The WebVR API does not allow to enter VR mode automatically. It requires a user gesture like a click that cannot be synthetized like your example does. The only exception is when a page enters VR mode after user gesture, new pages are granted permission to enter VR automatically after navigation. A-Frame already accounts for the scenario and no extra application code is necessary.
Firefox also grants permision to enter VR automatically on page reload. That’s why you might be seeing a different behavior on desktop. Your code is not necessary, A-Frame auto enters VR automatically already. This case is not covered in the Oculus Browser

How to block hardware Back button and re-login again

I have implemented below navigation for my app which has login and logout feature.
How to block hardware Back button and re-login again. Below is the flow:
1) Login page is the MainPage when App launch
MainPage = new Login();
2) After successfully login, user will be navigated to MainMenu Page
NavigationPage NP = new NavigationPage(new MainMenu());
App.current.MainPage = Np;
In MainMenu:
1) How to I override the Hardware button for iOS and Android (but iOS has no Back Button in current ipad and iphone).
This is what I got so far to stop back button.
protected override bool OnBackButtonPressed()
{
base.OnBackButtonPressed();
return false
}
1a) How to detect if device is iOS and Android phone? Since iOS has no back Button, will onBackButtonPressed() apply to it?
1b) will putting return false before or after base.OnBackButtonPressed(), make a difference?
2) User logout
in the beginning: Login -> MainMenu: in MainMenu page, user click Logout button
void LogoutButton()
{
Navigate.PopModalAsync(new Login());
}
will this cause any problem since the first time login, MainPage is App.current.MainPage = Np;
Now what is the Mainpage = ?? when user click Logout button?
What happen when user login again? Which Navigation method I should use to go back to Login Page?
Thanks
Let me start by saying that asking multiple questions at once isn't really according to the StackOverflow guidelines. To answer your questions:
1) How to I override the Hardware button for iOS and Android (but iOS
has no Back Button in current ipad and iphone).
The method you're overriding does indeed stop the hardware back button. It does not however stop every method a user has to go back. What you could do instead is create a separate Activity for your login and decorate that with the following:
[Activity(Label = "MyApp",
Icon = "#drawable/ic_launcher",
MainLauncher = true,
NoHistory = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
ScreenOrientation = ScreenOrientation.Portrait)]
public class LoginActivity : FormsAppCompatActivity { }
The NoHistory = true part is the interesting one. This means it won't be included in the Android navigation stack so you can't go back to it using the back buttons.
1a) How to detect if device is iOS and Android phone? Since iOS has no
back Button, will onBackButtonPressed() apply to it?
No. OnBackButtonPressed does nothing on iOS. It will not be called.
2) User logout in the beginning: Login -> MainMenu: in MainMenu page,
user click Logout button will this cause any problem since the first
time login, Now what is the Mainpage?? when user click Logout button?
What happen when user login again? Which Navigation method I should
use to go back to Login Page?
You can swap out the MainPage as needed. This will also help you when it comes to the back button. On app startup you can check if the user is logged in already. If he is, you set the Current.MainPage to your main menu page. If not you set it to the login page. When the user has successfully logged in you set the Current.MainPage to the main menu page. Since you set the main page, you get a completely new navigation stack, so the back button will not make the app go back to the login page.

Xamarin Forms - Getting Rid of Back Button In Nav Bar

Lets say the first page in the app is the login page and then it takes me to do the main menu screen, is there a way to get rid of the back button in the main menu navigation bar, like get rid of the login page stack?
thank you
In Xamarin.Forms 1.3 and greater you can use
NavigationPage.SetHasBackButton(this, false);
In Xaml you can add:
<ContentPage ....NameSpaces etc....
NavigationPage.HasBackButton="False"
Title="MyPage">
</ContentPage>
You can avoid having the Back button if you replace the Navigation.PushAsync(page) to Navigation.PushModalAsync(page) in your login page's code. Post some code if this somehow doesn't apply
This has to do with how navigation works in the underlying OS (at least in iOS that's the case) - there is a Navigation Controller which serves for pages to transition between each other and have a trace of previous screen so the user can go back.
There are 2 ways to get rid of back button:
1) You can remove navigation bar from Xaml using Xamarin.Forms using below code
NavigationPage.SetHasNavigationBar (this, false);
Where this stands for current page / form instance.
2) Follow below mentioned steps
Navigate to login page when the app is loaded with Normal ContentPage instance of Login Page
Navigate to Main page from Login page using PushModalAsync and provide the main page instance as NavigationPage
And then from all the other pages, you can use PushAsync and it'll let you navigate to all the pages without any error.
Hope this helps!
By using CustomRenderer, you call this function in ViewWillAppear in your customized view controller
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
this.ParentViewController.NavigationItem.SetHidesBackButton (true, false);
//remember to use ParentViewController to reference to the NavigationViewController (if your contentPage is direct under a navigation controller. I don't know why but Xamarin must have a bug with SetHidesBackButton. If you call with this.NavigationItem.SetHidesBackButton(...), it should not work.
... other implements here ...
}

How to impliment a jquery dialog window that acts as the windows message box?

I am implementing a jquery dialog which acts as the windows message dialog in asp.net.I want to build a dialog in jquery which should wait until the user send the confirmation and the asp.net code execution should stop unless until I click on the confirmation box with ok and cancel button.How I can implement this dialog. I am using the ScriptManager.RegisterStartupScript in the code window in asp.net.I removed the default message confirmation window of asp.net.I want to build the same message window with jquery...
Is it possible?
Why can't you use "confirm" function that is part of javascript ?
Look on this example:
...script type="text/javascript"...
function confirmation() {
var answer = confirm("Leave http://stackoverflow.com?")
if (answer){
alert("Bye bye!")
window.location = "http://stackoverflow.com";
}
else{
alert("Thanks for sticking around!")
}
}
.../script...
may be this example helps you.

Resources