connect to quickbooks, refresh app - intuit-partner-platform

In my app I have the 'Connect To QuickBooks' button that works as it should. When it is clicked it opens a window that allows the user to sigh in to their company. My problem is that I need to refresh my app to show the new information (Company name, etc), but I have not been able to find a way to refresh my app from the OauthHandler.aspx, that is opened in another browser window, by the 'Connect To QuickBooks' call. I must not be understanding something, can anybody help.
Thanks

Use the following in OauthHandler.aspx-
My refreshed page is default.aspx. Please set the page you want for your application.
<script type="text/javascript">
try {
var parentlocation = window.parent.opener.location.hostname;
var currentlocation = window.location.hostname;
if (parentlocation != currentlocation) {
window.location = "/default.aspx";
}
else {
window.opener.location.href = window.opener.location.href;
window.close();
}
}
catch (e) {
window.location = "/default.aspx";
}
</script>

Related

Log in with PayPal: Closing the login window to return to main site

I have successfully integrated PayPal Identify/Login but the issue is, the site (my return URL) opens up in the PayPal popup dialogue where the client logged in.
I want the login window to close and then have the main calling window go to the return URL, so the user continues on the main screen.
I can't find any details on how to do this on the PayPal Developer Docs. Is there an option in the button render that I am missing?
Current code:
paypal.use( ['login'], function (login) {
login.render ({
"appid":"My_API_ID",
"authend":"sandbox",
"scopes":"openid profile email address",
"containerid":"paypalLogin",
"responseType":"code",
"locale":"en-us",
"buttonType":"LWP",
"buttonShape":"pill",
"buttonSize":"lg",
"fullPage":"false",
"returnurl":"http://mysite/php/paypal/paypal_api_login.php"
});
});
The redirect back happens in the window. Add JS code there to save the URL info or redirect the opening window (set window.opener.location.href) and window.close() if desired.
Not tested but should be as simple as:
<script type="text/javascript">
if(window.opener) {
window.opener.location.href = window.location.href;
window.close()
}
</script>
or maybe better to also add and check for an additional parameter
<script type="text/javascript">
const REDIRECT_PARAM = '&redirected_opener=true';
if(window.opener && !window.location.href.includes(REDIRECT_PARAM)) {
window.opener.location.href = window.location.href + REDIRECT_PARAM;
window.close()
}
</script>

removeBackView() not working in Ionic?

JS code
console.log('Login Success');
$ionicHistory.removeBackView();
I am trying to stop to get the login view after login. But even I was logged in, if I click on back arrow of the browser, I am getting the login page. But Once I logged in I should get home page if I click on back arrow. .removeBackView() is not working properly. Please help me.
Even $ionicHistory disableBack also not working
I was having this problem. Putting removeBackView() in the next state didn't work. So instead I added this to the previous state, right before $location.path( '/app/myFirstPage' )
$ionicHistory.nextViewOptions( {
disableBack : true
} );
I also face same type of problem so use another concept, I think its help you.
if ($state.current.name == "app.home" || $state.current.name == "login") {
$ionicPopup.confirm({
title: "Confirm",
template: "Want to exit?"
}).then(function (res) {
if (res) {
navigator.app.exitApp();
}
});
} else {
navigator.app.backHistory();
}

Click Anywhere Pop Up

I'm trying to create a popup (new window) that appears when a person clicks anywhere on the page , but the problem is that my script creates a new tab for every click . I created a blogspot account just for test : http://faqetest123.blogspot.al/
what should I do for that ?
(example of a site that is using the popup that im trying to create is :atdhe.so)
Here is my code :
<script type="text/javascript">
document.onclick=function()
{
window.open('http://www.facebook.com');
}
</script>
Thanks
The window.open() function returns a reference to that window. So you should be able to use that reference to navigate to a new URL at a later time. Something like this:
var myPopup;
document.onclick=function()
{
if (!myPopup) {
myPopup = window.open('http://www.facebook.com');
} else if (myPopup.closed) {
myPopup = window.open('http://www.google.com');
} else {
myPopup.location.href = 'http://www.stackoverflow.com';
}
}
Note that this also attempts to check if the user has closed the pop-up and re-opens it.
Edit: Based on your comments below, it looks like I misunderstood. In order to have the popup execute once and then not again, you can simply remove the event handler after processing it. Something like this:
document.onclick=function()
{
window.open('http://www.facebook.com');
document.onclick = null;
}

Facebook login popup doesn't close after login on iOS8

I'm testing my web app login flow on the iOS8. I notice that on iOS8, the login dialogue pops up, but after logging in, it just stays there, showing a blank page.
The login works, because the page behind it shows the user information, but the popup just stays there, while it should close automatically. On iOS7 and iOS6 it does close. On desktop browsers it closes too.
I've tested some other random sites (for example brainfall.com) using FB.login(): same thing.
Does anyone have a fix for this?
Any help is much appreciated!
Check this:
fb_window_redirect
Override de window.open method. This allows you to know what windows are opened.
Then you can redirect the window opened by the FB SDK.
...
window._open = window.open; // saving original function
//Override the function
window.open = function(url,name,params) {
var new_window = window._open(url,name,params);
if (typeof onWindowOpen === "function") {
onWindowOpen(url, name, params, new_window);
}
return new_window;
};
...
var openedWindows = [];
var fbWindows = [];
function onWindowOpen(url, name, params, new_window) {
...
// Filter the facebook oauth request
if (url.contains('facebook.com')
&& url.contains('oauth')) {
fbWindows.push(new_window);
}
openedWindows.push(new_window);
}
...
//On fb login button pressed callback:
FB.login(function(response) {
//Try login
if(response.authResponse) {
//Login succesful
// Fb window redirect.
// see onWindowOpen
var fbwin = fbWindows[0];
var redirect_url = ''
fbwin.location = redirect_url;
}
},
{scope: 'email,publish_stream,user_birthday'});
...

webworks blackberry 10 window.open twitter facebook

i am just trying to implement facebook and twitter in my Webworks App and cannot get them work together.
I am using the FaceBook-OAuth-2 and the Twitter-OAuth-1 sample and i just put both stuff together and my problem is that only the first startOAuth() opens a window in the app to login the second doesn't so if i first clicked facebook it works after when i try twitter nothing happens.
https://github.com/blackberry/BB10-WebWorks-Samples
thanks
function setClickHandlers() {
console.log('set click handlers');
var fb = document.getElementById('facebookOn');
fb.addEventListener('click', function(e) {
// if the childWindow is already open, don't allow user to click the button
if(childWindow !== null) {
return false;
}
e.preventDefault();
toast('Contacting Facebook...');
setTimeout(function() {
startOAuth();
}, 500);
});
console.log('set twitter click handlers');
var tw = document.getElementById('twitterOn');
tw.addEventListener('click', function(e) {
// if the childWindow is already open, don't allow user to click the button
if(childWindow !== null) {
return false;
}
e.preventDefault();
toast('Fetching access token...');
setTimeout(function() {
twittergetAccessToken();
}, 500);
});
}
I would start by adding some debug code in your click handler to see if that's getting called when you click the button in the first place.
If it is, then I recommended you use Web Inspector (console) to see if there are any errors. If there are, they'll show up there.
Good reference for Web Inspector here - http://developer.blackberry.com/html5/documentation/web_inspector_overview_1553586_11.html
If the click handler is not being fired then perhaps you have the wrong element ID, or the setClickHandlers function is not being executed.