cannot get previous page name on device using ionic2 - ionic2

I am using ionic 2.
I update my ionic version.
Ionic version 3.4.0
If user not authenticated my root page is Login Page. after user logged in and go to dashboard Page.user When click on hardware back button go to Login Page.
I Need if user authenticated click on hardware back button does not go to Login page.Display msg "Do you want to exit?"
Because I need get previous page name.
I used this Code
this.navCtrl.last();
It's work fine on browser.But not work on device.
I run my app.
I consoled the value
t {_isHidden: false, willEnter: e, didEnter: e, willLeave: e, didLeave: e…}
and its return the page name is 't'.

Then you can pass the name of the current page while you route to a new page. Then you can use that name from new page.
Example (Assume we are routing from page A to page B)
in page A
this.navCtrl.push(B,{previousPage:'A'});
in page B
class B{
constructor(private navParams: NavParams) {
let previousPage= navParams.get('previousPage');
}
}
====UPDATE=======
I cant understand why you want previous page name for achieve this. any way your requirement can achieve as following.
in your app component set root page as loginPage.
public rootPage: any = LoginPage;
Then, If user login success. route to dashboard page by calling
navCtrl.setRoot(HomePage); // here user will route to the home page and set it as root
You can re change the root page as login page when user click sign out
navCtrl.setRoot(LoginPage);
then if user is authenticated root page will be HomePage and if user click back button user will leave the app.
Hope this will help you :) enjoy Ionic ;)

Related

How to use Social-Auth-Django-App with Facebook's https://m.me/

I tried using hyperlink and supplied it with my actual Facebook Username and it's working. But the problem is my actual Facebook Username is different from the Username provided by Social-Auth-App-Django. So I tried User ID instead but it's not working either.
By the way what I'm trying to do is an online shopping website and when a user clicks the hyperlink, he/she will be redirected to the seller's Facebook Messenger account to start a conversation.
This is the first line of code that I tried which is working.
Send Message to Seller
And this is the code I used using Social-Auth-App's provided data:
Send Message to Seller
And I also tried this:
Send Message to Seller
Any idea how I can use Facebook's m.me/ using the provided data by Social-Auth-App-Django? Or if you can suggest me other ways other than m.me/ I will greatly appreciate it. Thank you very much!
First Go To Setting.py And Put This Code End Of All Codes:
AUTHENTICATION_BACKENDS = [
'social_core.backends.facebook.FacebookOAuth2',
]
Second Go To FaceBook Developer In This Address :
https://developers.facebook.com
And Make One Account There.
After go To My Apps And Then Click On Create App And Then Put Your Website Name ((Attention...If You Use Your Local Host You Need To Put One Domain Name For Your Local Ip)) And Your Email And Click On Create App ID And In Your Dashboard Looking For Facebook Login And Click On Set Up .
And Then In First Step In Web Window Put Your WebSite Name For Local Host For Example Put mysite.com:8000/ And Click On Save And Other Options Just Cross .
Now In Your Dashboard On The Left Side Click On Setting And Then Basic If You See Your APP ID And Your APP SECRET Put This Two In Your Settings.py After That Last Code .
SOCIAL_AUTH_FACEBOOK_KEY = 'Put Your App Id Code Here'
SOCIAL_AUTH_FACEBOOK_SECRET = 'Put Your App Secret Code Here'
If You Want To Take User's Email Also You Can You This As Well .
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
Now In You Dashboard Go To Settings And After Go To Basic An In Field App Domains Put Your Website Name Also Go To Settings After Advanced And Put Website Name In Domain Manager With CLick On Add a Domain .
Now Again In Dashboar Go In Products+ Part And Click On Facrbook Login After Settings And Check These Option Be Active(Yes) :
• Client OAuth Login
• Web OAuth Login
• Enforce HTTPS
• Embedded Browser OAuth Login
And IN This Form Your Are Now Also Go In This Field Valid OAuth Redirect URIs And Put This URL :
exapmle.com/social-auth/complete/facebook/
And Put Your Button In Your Website Page That Have This Login Auth :
<li>
Sign in with Facebook
</li>

Master detail Interactive grid in Apex

I have created a master (Department )detail(Employee) pages in Apex19.1 both pages are interactive grids.In Department grid I create a form to add new department. I am using inbuilt Edit and delete functionalities of IG .
When I edit or delete anything in the IG , Cant save changes ,In debug following error I am getting
AUTHORIZATION WITH ID #11442180234008966638 NOT FOUND - return true
I dont have any custom authorization .
Signin user is apex admin.

Ionic 2: Removing login page from navigation stack, causes nav.push cease to work in Dashboard page

I am having this weird issue. When user logs in, user is forwarded to dashboard. But before this I remove login page from navigation stack so that when user
presses hardware back button they are not taken back to login page (as they're already logged in).
Following is my login method of login page
loginUser(){
this.loading=this.loadingctrl.create({
content:"Logging in, please wait..."
});
this.loading.present();
this.ajaxRequest = this.webservice.loginUser(params).subscribe(data => {
this.loading.dismiss();
if(data.status =="ok"){
this.navctrl.push(DashboardPage).then(()=>{
const index = this.viewCtrl.index;
this.navctrl.remove(index);
//Above two lines finds index of current page and removes current page, i.e. login page from navigation stack
});
}else{
//show error alert
}
}, err =>{
this.loading.dismiss();
});
}
This code works well but however encountered a weird issue
PROBLEM
Any button in dashboard, or in swipe menu doesn't work.
Each link/buttons calls some method which navigates to some other page. Example method -
gotoProductsPage(){
console.log("method gotoProductsPage is called");
this.navCtrl.push(ProductsPage);
}
I can see the methods are being called because i can see log being printed in console. The only thing is this.navCtrl.push(ProductsPage);seems to be not working.
I did further test and commented the lines const index = this.viewCtrl.index; and this.navctrl.remove(index); in login method of login page.
Now all the button works. But hardware back button takes user back to login page.
Can anybody enlighten me why my app is having this weird behavior??
Thanks
There is no reason to manipulate the Navigation Stack by trying to get LoginPage index and removing it.
I suggest simply setting the DashboardPage as the root of the navigation stack.
if(data.status =="ok"){
this.navctrl.setRoot(DashboardPage).then(()=>{
console.log("done");
});
}else{
//show error alert
}
Now it will not navigate to login page on back.

how to redirect customer login after he register in opencart v 2.1?

I am using opencart v 2.1 my problem is when a new customer is registering, it is redirecting to account/success and after clicking on countinue button the customer is not redirecting to his account page instead redirecting to account/login please help me.thanks in advance
This is the function which is called when a customer registers on an OpenCart 2.X store.
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->customer->login($this->request->post['email'], $this->request->post['password']);
unset($this->session->data['guest']);
// Add to activity log
$this->load->model('account/activity');
$activity_data = array(
'customer_id' => $customer_id,
'name' => $this->request->post['firstname'] . ' ' . $this->request->post['lastname']
);
$this->model_account_activity->addActivity('register', $activity_data);
$this->response->redirect($this->url->link('account/success'));
}
The $this->customer->login() section auto logs them into their new account but they are being redirected to the login page again because it has not been successful.
You might have a setting in your OpenCart store which means customers need to be approved by admin, or need to verify their email address before they can checkout. You can find out by logging into your admin section and going to:
Sales -> Customers -> Customer Groups -> Edit -> set "Approve new customers?" to No

FB.api doesn't bring profile name

I am using Facebook JS sdk to show news feeds. the app works well for many users for for some users who have authorized my app doesn't bring reasonable result.
I use following code to get basic profile info which works for some users but for some it doesn't:
FB.api('/' + id + '?access_token=' + access_token, function (response) {
var strTitle = response['first_name'] + " " + response['last_name'];
});
In response object I receive only id, birth date, email, profile link but name is not available. Interestingly when I open profile link in my browser facebook says:
"Sorry, this page isn't available
The link you followed may be broken, or the page may have been removed."
after that my code can bring its posts but again the from name of the posts is missing in response object. The permissions list is attached as picture.
I can't understand what is going on and how can i fix this issue. Any help please?
The problem is that you are using the App center permissions feature (previously known for Authenticated referrals).
Use these settings to enter the set of permissions your app requires when displayed in App Center
You should be passing a login url with the scope array of permissions in JS SDK.
FB.login(function(response) {
// handle the response
}, {scope: 'email,user_likes'});
or via a login button
<div class="fb-login-button" scope="email,user_likes" data-show-faces="true" data-max-rows="3">Login with Facebook</div