SoundCloud API stream on ios / iphone - ios

Should the stream action via SC API / Javascript SDK 2.0.0 work on iOS/Safari?
I'm finding that it doesn't with the trivial example below.
It seems like SoundManager is capable of knowing how & when to use html5. Am I mistaken?
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Sound Cloud iOS test</h1>
<script src="//connect.soundcloud.com/sdk-2.0.0.js"></script>
<script type="text/javascript">
SC.initialize({
client_id: "YOUR_CLIENT_ID"
});
SC.stream(
'/tracks/293',
function(sound) {
sound.play()
}
);
</script>
</body>
</html>

You cannot force play or download any audio/video files in Safari on iOS devices without user initiation.
In Safari on iOS (for all devices, including iPad), where the user may
be on a cellular network and be charged per data unit, preload and
autoplay are disabled. No data is loaded until the user initiates it.
This means the JavaScript play() and load() methods are also inactive
until the user initiates playback, unless the play() or load() method
is triggered by user action. In other words, a user-initiated Play
button works, but an onLoad="play()" event does not.
This plays the movie: <input type="button" value="Play" onclick="document.myMovie.play()">
This does nothing on iOS: <body onload="document.myMovie.play()">
You will need to wrap your play action into a button, so that the audio stream is opt-in rather than automatic.
Check this article in the Safari docs for reference.

Related

Smart Banner not coming

I have published my app on iOS Appstore. To show smart banner I use following code on my webpage.
<html>
<head>
<title>Kinjal's Games</title>
<meta name="apple-itunes-app" content="app-id=6444216110, app-clip-bundle-id=com.kinjal.brainbooster"/>
</head>
<body>
Yo
</body>
</html>
When I load webpage, it shows banner for 1 sec and then disappears immediately.
To verify, I tried by using other app's Appstore id. If I try using facebook's app id, it works.
<meta name="apple-itunes-app" content="app-id=284882215, app-clip-bundle-id=com.kinjal.brainbooster"/>
But it doesn't work only with my app id
<meta name="apple-itunes-app" content="app-id=6444216110, app-clip-bundle-id=com.kinjal.brainbooster"/>

iOS - How can I detect that the current wifi needs to go through a confirmation screen?

Quite often when joining a public wifi you need to go through a confirmation screen before getting access to the broad Internet. Most of the time after connecting through Settings, you'd open Safari just to do that confirmation before using your apps.
How can I detect this state from my app and show a web view to let the user do that form the app?
You can use this URL: https://captive.apple.com/hotspot-detect.html
If you get HTTP statuscode 200, and something other than 'Success' in response, then you're probably talking to a captive portal.
Or you can of course create your own hotspot-detect page:
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Success</TITLE>
</HEAD>
<BODY>
Success
</BODY>
</HTML>

Convert Custom URL scheme to QR code (IOS)

My question is what can I do to convert the custom URL scheme to a QR code that can open an app.
Let's say I have a custom URL (myScheme://). It works if I type it on my phone's browser.
But if I just convert it through some online qr code generator, the qr code reader is not going to open the url in browser and just return me a plain text.
Does it mean I need to build an own QR code reader to handle it?
I think it depends on QR Code Reader apps. In my situation I have a custom URL (itms-services://?action=download-manifest&url=xxx) QR Reader for iPhone works. But some customers said: "I can't install the app. QR just opens Safari.". There are so many QR Reader apps and we don't know which one is used.
But you can use your own web-site something like this:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0, maximum-scale=1.0" />
<title>Site Name</title>
<style>#media screen and (max-device-width:480px){body{-webkit-text-size-adjust:none}}</style>
<!-- implement javascript on web page that first first tries to open the deep link
1. if user has app installed, then they would be redirected to open the app to specified screen
2. if user doesn't have app installed, then their browser wouldn't recognize the URL scheme
and app wouldn't open since it's not installed. In 1 second (1000 milliseconds) user is redirected
to download app from app store.
-->
<script>
window.onload = function() {
<!-- Deep link URL for existing users with app already installed on their device -->
window.location = 'yourapp://app.com/?screen=xxxxx';
<!-- Download URL (MAT link) for new users to download the app -->
setTimeout("window.location = 'http://hastrk.com/serve?action=click&publisher_id=1&site_id=2';", 1000);
}
</script>
</head>
<body>
<!-- button to Download App for new app users -->
<form action="http://hastrk.com/serve?action=click&publisher_id=1&site_id=2" target="_blank">
<input type="submit" value="Download" />
</form>
<!-- button to Open App to specific screen for existing app users -->
<form action="yourapp://app.com/?screen=xxxxx" target="_blank">
<input type="submit" value="Open App" />
</form>
</body>
</html>
Then you should generate QR with website url. It will open in Safari and will redirect your app. (I hope so.)

Metarefresh is failing when Youtube iOS app is installed

Why is one metarefresh to YouTube failing while another is succeeding? And why does it have anything to do with whether Youtube as an app is installed?
We have two metarefresh links that take users to videos from an iOS app.
(1) This page refers properly to Youtube whether the Youtube iOS app is on your device or not:
The invoking link is: http://ourURL/videos/ourpage.html
The receiving HTML page is this:
<!doctype html>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=http://youtu.be/tJ08IHetnbU" />
</head>
<body>
</body>
</html>
(2) The referral page that breaks is designed the same way but works only if the Youtube app is NOT on your iOS device. If the Youtube app is on your device, we see "Playback error. Tap to retry." "Error loading Tap to retry"
The invoking link is: http://ourURL.com/videos/ourpage2.html
<!doctype html>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=http://youtu.be/0FZbh-Cqfg4" />
</head>
<body>
</body>
</html>
The answer turned out to be a caching issue in the YouTube app.
It appears the Youtube app relies on the Safari cache. The Meta-refresh had referred to different video links before - so the new updated links failed.
Interestingly, for whatever reason, Safari is not using its cache and showed the proper video.
After going to Settings, Safari and "Clear cookies and data" - the YouTube App started showing the referral pages properly again.

Safari meta refresh not working with my iphone app

I have an app that allows a user to install a configuration profile. I'm doing this by presenting a button on a view controller that when clicked, displays a very basic HTML page (using Cocoa HTTP Server) that has an iframe which will open the .mobileconfig file and allow the user to install it. After the user installs the profile (or indeed, cancels installation) iOS automatically switches the user back to the safari app. I've setup custom URL schemes and that works perfectly.
What I'd like to do is automatically redirect the user back to the app after they've installed the profile. I thought the best way to go about this is the http-equiv="refresh" meta tag but it seems it'll only redirect the user if they complete setup in under the refresh time (if that makes sense).
For example, if I'm able to install the profile and be switched back to safari in 3 seconds - it works. If I take 5 seconds or more to install the profile I won't be redirected. It seems like the meta refresh timer is running in the background and if Safari isn't in the foreground - it won't do it.
My question is then how do I automatically redirect the user back to my app once the profile is installed regardless of how long it takes them? I've had a look at using javascript but as you can turn that off in iPhones I'd rather not use it.
Index.html
<html>
<head>
<meta http-equiv="refresh" content="4;url=myapp://">
<meta http-equiv="content-type" content="application/x-apple-aspen-config; charset=UTF-8">
<title>Profile Installer</title>
<style>
#main{
font-family: "Helvetica";
padding-top: 500px;
padding-left: 80px;
padding-right: 50px;
}
p{
font-size: 27pt;
color: #FFFFFF;
}
</style>
</head>
<body bgcolor="#74caf2">
<div id="main">
<p>Downloading configuration profile. Please wait.</p>
</div>
<iframe width="1" height="1" frameborder="0" src="settings.mobileconfig"></iframe>
</body>
</html>
This simple JS is great to add to your code, it eliminates the problems that you mentioned with the content-refresh option in html. I understand that some users do switch off the JS in the mobileSafari but in my experience and some stats we gather from app I develop, that is 0.001% of all users.
<script type="text/javascript">
function Redirect()
{
window.location="urlScheme://";
}
setTimeout('Redirect()', 2000);
</script>

Resources