Xamarin.Forms navigation stack flow - xamarin.forms

I'm trying to work out the correct way of structuring the navigation for my Xamarin.Forms application.
Please note the LoginPage is currently set as the application's MainPage.
The intended (visual) structure is as follows:
CheckPermissionsPage ➜ LoginPage ➜ HomePage
I am following a MVVM structure, so my LoginPageViewModel is displaying a modal of CheckPermissionsPage within it's constructor as so:
await Application.Current.MainPage.Navigation.PushModalAsync(new CheckPermissionsPage());
The idea is that the check permissions page validates the application has permissions to specific services and if it does, the page automatically closes. The user must then login to the application, after which the HomePage is displayed.
How would I structure the LoginPage so that the CheckPermissionsPage modal can be displayed/hidden based on permissions state. Consequently, after a successful login, the HomePage is displayed (without an option to return to the LoginPage). Thanks!

I ended up changing the application MainPage to navigate throughout the pages. So my initial application main page is now the CheckPermissionsPage. Should permissions be granted I then run Application.Current.MainPage = new NavigationPage(new LoginPage());. After logging in, the HomePage is displayed with Application.Current.MainPage = new NavigationPage(new HomePage());. This probably isn't the most ideal solution, but it does allow me to prevent back navigation for my LoginPage.

Related

Route to /login and /{PageName} in an asp.net app not working

In an ASP.NET Blazor App with Identity I have a page with the page routing
#page "/{PageName}"
When I change the page routing of the login page in Areas/Identity/Pages/Login.cshtml to
#page "/login"
and enter the URL 'localhost:44397/login', the login page shows up as expected.
However, if I follow the link in header bar that I have adapted in LoginDisplay.razor to Log in, the URL changes to 'localhost:44397/login' as expected, but the login page does not appear. Instead, the above page is rendered, where the PageName parameter is set to 'login'.
Endpoint routing obviously works if the URL is entered manually but fails when clicking a link, as if half of the routing middleware would have been bypassed. I tested this with a fresh Blazor template and have no more ideas where to look for the bug.
Accoring to this article, a click on a hyperlink in a Blazor component is intercepted automatically. While the URL in the browser is updated, the request is not sent to the browser but the page is renderd by Blazor. In my case, Blazor can find a suitable page (the one with the #page "/{PageName}" directive) and renders it.
To force loading of the page, NavigationManager can be used:
Login
The href is necessary to render the link with the typical layout. It's probably not the most elegant solution but at least it works.

Cant login with asp.net core Identity

So I am working on a project. Everything seems fine. I dont have any error or anything like that.
But when I am trying to login into my website that I created with Identity, nothing happens. All the tables are in my database as it should be.
In the output in visual studio it says:
info: GetThingsDoneMVC.Areas.Identity.Pages.Account.RegisterModel[0]
User created a new account with password.
info: GetThingsDoneMVC.Areas.Identity.Pages.Account.LoginModel[0]
User logged in.
So it works. But when I try to login nothing happens. I get redirected to the home page and I still don't see that I am logged in. It still says up in the corner "Register" and "Login".
Have anyone else had this problem before? Any idea on how to fix this?
I also had it in the past and the problem was that I did not add #inject SignInManager<Identity> SignInManager and #inject UserManager<Identity> UserManager to the _LoginPartial.cshtml file. Also make sure that in the _ViewImports.cshtml file you have added #using Microsoft.AspNetCore.Identity and #using Myproject.Models if you have a seperate models project.
I fix the issue by going to the startup.cs and
changing
services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true)
to
services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = false)

How To Create Facebook Application programmatically?

I want to create a facebook app from within my code.
When done manually, I have to go to developers.facebook.com, go to the apps section and click on "create a new app". This will create a new app and facebook will ask me to provide the basic information like
App display name
App namespace
Site url
canvas url
This will create a new app.
I want to do the same automatically. Is it possible with RestFb?
Answer to your question is, NO you can't do that by any Facebook method and the reason for the same is similar to the reason that due to which you can't create Page, Facebook user account, Group through Facebook's API and it is security which other poster has listed out.
Think about it. If you could do it by code you could atuogenerate infinite apps automatically. It will be a dangerous security hole to facebook. So, you have to do it manually.

tracking "add a tab" page installs on other pages

We have a public page on our product service page http://www.facebook.com/realestateagentdirectory?sk=app_171700809577806 that allows anyone to add our "find an agent" app to their own page.
Is there a way to know when FB users install our app on their own FB pages - via page or app insights, or in a different way? Right now we have no clue who/when adds our app to their page.
One way that would work, obviously, (which would be an overkill for this and it would require users to install another app, etc.) is to do this (installing/adding a tab on your page) from within another app which keeps track of all tab additions to other pages.
But we're looking for an easier way of knowing this data. Thanks!
You can track first visit to Page Tab Application canvas via parsing signed_request argument to collect pages who had installed application.
Later you can use FQL table page checking for has_added_app field to ensure tab is installed/removed

Running Canvas app in a Tab

This is my first Facebook app and I'm on quite a tight deadline so forgive me if any of this is a dumb question.
I've set up a Canvas app, I've got it to authenticate by passing the parameters to the facebook URL:
https://www.facebook.com/dialog/oauth?client_id=1234&redirect_uri=MY_APP_URI
I can then get the user_id and name of the user, which for this particular app is all I need. It runs fine in the Canvas page.
Problem is I can't get it to run in a tab, it always redirects to the Canvas, which is not what I want - I need it to run within the context of my client's Facebook page. I've been trying to find examples of setting it up but everything seems to be out of date compared to what I'm seeing in the App settings.
My settings at the moment are:
App on Facebook
Canvas URL: http://localhost/facebook/
Canvas Page: http://apps.facebook.com/MYAPP
Page Tab
Page Tab Name: My test app
Page Tab URL: http://localhost/facebook/
I presume I'm missing something obvious, so if someone can advise I'd be grateful. For what it's worth I'm using .Net webforms and have the C# SDK installed, but don't think I'll need to really use it for this example.
EDITED TO ADD
I'm sure its to do with the authorization - I've followed the guide here developers.facebook.com/docs/appsonfacebook/tutorial on how to redirect the page back with the authorization payload, but obviously doing that has kicked it out of the tab and into the main Canvas again. I need to to stay where it is, if such a thing is possible.
localhost points from your local machine to itself. Facebook does not know what localhost relates to and cannot load the app. You need to make your app accessible from outside of your machine.
It was the fact that I was still redirecting the url, when you run in a tab you don't need to redirect to another url to get the user data, it's just there waiting.

Resources