I have asked a question in Hide div in a Custom Tab opened from a Trusted Web Activity
Let me explain a little bit more.
My twa website is https://www.monsoonmalabar.com/
In the above site there is a link to external site which is https://keralapsc.monsoonmalabar.com/ when clicking this link in twa app, this link opens in in-app browser. In that in-app browser(website: https://keralapsc.monsoonmalabar.com) there is a button floats left side with link https://play.google.com/store/apps/details?id=com.monsoonmalabar.app.
I want to hide that link(button) when user using twa(in-app browser). According to your suggestion in the stackoverflow site, I added the external link as https://keralapsc.monsoonmalabar.com/?hideDiv=true
And added a code in external site as
<script>
var url_string = window.location.href; //window.location.href
var url = new URL(url_string);
if(url.searchParams.get("hideDiv")) {
document.write('<div></div>');
} else {
document.write('<div id="play_button"><a class="btn_openinapp" data-attr="btn_openinapp" href="https://play.google.com/store/apps/details?id=com.monsoonmalabar.app" style="left: 0px;"><i class="fab fa-google-play"></i></a></div>');
}
</script>
Now what happens is during the first visit from twa(which has hideDive=true) the button disappears. But when I continue to surf external site by going to another page in that external site button shows again. Maybe I didn't understand you correctly. Can you please explain a little bit more with codes. I am new to coding. My twa app is https://play.google.com/store/apps/details?id=com.monsoonmalabar.app
Below is the screenshot of external link marked.
The solution is to save the hideDiv information into the sessionStorage, so you can load the information from there when navigating to other pages.
The code would look something like this:
<script>
// Set `hideDiv` to `true` on sessionStorage when we receive the `hideDiv` parameter.
const url = new URL(window.location.href);
if(url.searchParams.get('hideDiv')) {
sessionStorage.setItem('hideDiv', true);
}
// sessionStorage is persisted across page loads, but cleared if the tab is closed and
// a new navigation session starts. We check if it's been set to `true` in this session.
if(sessionStorage.getItem('hideDiv')) {
document.write('<div></div>');
} else {
document.write('<div id="play_button"><a class="btn_openinapp" data-attr="btn_openinapp" href="https://play.google.com/store/apps/details?id=com.monsoonmalabar.app" style="left: 0px;"><i class="fab fa-google-play"></i></a></div>');
}
</script>
Related
I've developed a command palette for macOS. Over the last few days I've figured out a way to show the Notification Center inside my app.
I would like to mimic the behaviour of the real Notification Center when clicking a notification: open the corresponding tab when clicking in a browser notification.
However whenever I cannot figure out a way to do it programmatically, I can only tell macOS to open the link and it automatically opens the default browser and creates a new tab.
let url = URL(string: "https://www.google.com")! // this opens a new tab everytime
if NSWorkspace.shared.open(url) {
print("default browser was successfully opened")
}
As for the notification itself I do get all the info it contains: the app bundle id, the notification payload, and even a link (e.g. n#https://web.whatsapp.com#465718293123#c.us). I've seen some answers that rely on AppleScript but I would rather avoid it if possible. But if not possible... then happy to fallback to it.
Any ideas how to achieve this? Many thanks!
P.D. I've also tried some variations of the link such as: arc://web.whatsapp.com#1234567 or arc://n#web.whatsapp.com#1234567. At most this focuses on the browser but not on the tab.
I have a native iPhone app, which has a UIWebView component to it. I am trying to see if I can replicate the "Add to Home Screen" button that is present in the tab bar options in Safari.
Is this possible inside a UIWebView within a native app?
Thanks!
Brett
[I presume your question is about replicating the action associated with add to home screen, rather than replicating the appearance of the button itself (which being pedantic is what you actually wrote).]
As others have said this isn't possible.
What you could do is programatically launch Safari from within your app and give it the URL of a page to load which is your page.
When your page is loaded it has some sort of animation and shows the user where the add to home screen button is and tell them to press it after clicking a link which is displayed in your web page. When the users click on the link it takes them to whatever page it is that you would like saved to the desktop, and you hope they follow your instructions.
If you register your app to handle a proprietary url scheme the users can get back to your app from within Safari by clicking on a link using your app's url scheme.
The web pages that you seed Safari with must however be remote pages, you cannot give Safari a page in your app's bundle or that your app has downloaded as Safari cannot read pages from your app's sandbox.
The short answer is no, you can't. Apple does not let you.
Here's a similar question which may help you come up with other possibilities:
Javascript for "Add to Home Screen" on iPhone?
If I had to think of a work around off the top of my head, you could create an javascript pop-up which instructs them how to. It could say something like tap this button to go to mobile safari then tap action -> add to home screen.
Execute the Javascript with UIWebView's method:
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
Hope this helps.
You can use UIActivityViewController with your url as the activity items
NSArray *activityItems = #[title, url];
And then you can exclude the activities that you don't want. I think it´s the only way for now.
I have added a website to the iOS home screen. If a load open the website from the iOS home screen, it seem to be always loading a cached page. Even if I updated the page or delete the page entirely, it still load the original version.
It will load the updated page if I open the site directly from iOS Safari instead of clicking the icon on the home screen.
The site is hosted on Apache running Ubuntu 11.10.
I have added following inside
and added
in attempt to force it to load the updated page.
I have also tried clear the cache and cookie and history from iOS Safari setting and also rebooted the ipad and nothing seem to work.
Please help~!
This should do it, though it will result in double-loading of your page in instances where it is not initially loaded from a cached copy.
<script>
var url = window.location.href;
if (url.indexOf('rnd=') == -1) {
url = (url.indexOf("?") == -1 ? url + "?rnd=" : url + "&rnd=") + Math.random();
window.location.href = url;
}
</script>
So basically you would add http://mysite.com/myCoolPage.html to the iOS home screen, and then whenever the page is loaded in the browser it will redirect to http://mysite.com/myCoolPage.html?rnd=xxxxxxx, effectively preventing it from being cached.
I have an application in which i have a button. I want to open a fb login url in browser and when i login successfully then i want to come back to my application. So problem is that how i fix that?
i use this code for.
-(IBAction)add_account:(id)sender{
switch ( ((UIButton*)sender).tag ){
case 0:
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://graph.facebook.com/oauth/authorize?client_id=xxxxxxxxxxxxx&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=touch&scope=offline_access,publish_stream,read_stream"]];
break;
}
}
}
Thanks in advances...
You need to register an URL scheme for your own app. You can put the URL scheme in your app's project file on the "Info" tab, lower right is an "Add" button which allows to add an URL type. You can now edit that URL type in the list, especially filling out the identifier and more important the URL scheme. Assuming your URL scheme is "myapp":
Every URL starting with myapp:// now will be forwarded to your app. Now you simply have to implement application:openURL:sourceApplication:annotation in your application delegate which will handle all "myapp://" URLs. There you can, for example, extract information from the URL and show a specific view.
The myapp://-URL would of course go as redirect target in your original request.
I'm developing a Facebook application.
It can be seen here:
http://apps.facebook.com/tangram-girbaud/
When the user has to aprove the application, this comes to the screen:
A Facebook logo inside the canvas, and the user does not click the logo.
If you click that logo Facebook sends you to the aproval window.
Is there any way to override this view?
Thanks.
What you need to do is to redirect using the below script:
<script type="text/javascript">
window.top.location.href = "https://www.facebook.com/dialog/permissions.request?app_id=196403870434233&display=page&next=http%3A%2F%2Fwww.pilatosapp.com%2Ftangram-girbaud%2F&response_type=code&fbconnect=1&perms=publish_stream%2Cuser_about_me%2Cuser_birthday";
</script>
from frame info, address of frame is:
https://www.facebook.com/dialog/permissions.request?app_id=196403870434233&display=page&next=http%3A%2F%2Fwww.pilatosapp.com%2Ftangram-girbaud%2F&response_type=code&fbconnect=1&perms=publish_stream%2Cuser_about_me%2Cuser_birthday
As you somehow frame facebook.com, it doesn't show the content instead facebook logo.
you may inspect further why permission dialog opens not at window.top