I need to add a smart app banner for iOS and Android versions of a native app when users visit the client site on a variety of small screen devices. Using the meta tag method described here
for iOS devices, I'd like to also include the meta tag method for Android devices, if this exists. The code would also need to query if the user was viewing a particular page on this Wordpress site (query by page-ID) and what device they were actually viewing on.
I'm aware the meta tag for iOS needs to be in the format:
<meta name="apple-itunes-app" content="app-id=123467, affiliate-data=myAffiliateData, app-argument=myURL">
I've also read elsewhere the php query for the device is this:
<?php
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$droid = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
if ($iPod || $iPhone || $iPad){
//Display Smart App Banner prompt for iOS
} else if($droid){
// Display Smart App Banner Prompt for Android
}
But I'm not aware of the meta tag for Android, or how I'd combine them all together and check the page they are on (so banner doesn't display sitewide) and incorporate into Wordpress site.
Hopefully someone cn help me with some code to try in functions.php of child theme or via a meta tag plugin (or hook within Canvas theme).
Related
I am searching for a test automation tool that supports the following test case:
start an app on the smartphone
click on a button; the click on the button starts the browser and opens a web page in the browser, on the smartphone of course
enter some data in the browser
return to the app: the entered data must be visible now in the app
I have seen many test automation tools, that support app testing and browser testing. But there I have seen only situations where the browser is opened on the computer where the test automation tool runs; or cases where the browser is started separately on a smartphone.
Does anyone know a tool that supports testing the described communication between the app and the browser which was started by the app?
This can be done in the standard automated UI testing that comes with Xcode, XCUITest (i'm assuming the Android equivalent can do the same). I'm a fan of using the inbuilt stuff as you get full access to Swift/Objective-C and don't have to deal with any additional, buggy dependencies
E.g. I had a settings screen in an app that had multiple links to external resources. I had an automated test that tapped the buttons, waited a few seconds, then verified that safari contained the correct URL, then returned to the app.
Your usecase will obviously be more involved than mine, but here is a sample of navigating from app -> Safari -> interact with safari -> return to app
func test_ExternalLinks() {
// Hold onto a reference of our app that we are testing, and safari installed on the phone
let app = XCUIApplication()
let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")
// Query to get safari URL textfield
let urlTextField = safari.textFields["URL"]
// Navigate to settings screen
...
...
// Tap "About" button in our app
app.tables.staticTexts["About"].tap()
sleep(2)
// Tap URL bar so we can examine the full URL
safari.buttons["URL"].tap()
urlTextField.tap()
// Extract URL and compare to known value
var url = urlTextField.value as! String
XCTAssert(url == "https://...../about/", url)
// Return to our app
app.activate()
sleep(2)
}
After open webpage in app browser where phone number is set I need get phone number in popup for call.
Any plugin for phonegap?
GL
Not sure what your question means, but as far as I understand you need to make a call to the number on button click. Try the following in your HTML file:
<a class="button" href="tel://123456">1234563</a>
If you are getting the number from controller, use:
<a class="button" href="tel://{{number}}">123456</a>
Today I came across a feature request that I had not done before – dialing a number from within an app. Some quick research shows that its possible using a specific URI scheme.
What are URI schemes? Honestly Wikipedia does a better job than I ever could in describing them but I think of them as something that allows a specific piece of functionality to happen over the internet, and thus they are usually referred to as protocols. You probably have already seen them – the most common ones are http: and https: (for web browsing), and ftp:, among others. Some are unique to an application and really don’t qualify as schemes and are definitely not a “protocol”, such as mailto: (to open up the mail client on a person’s computer), javascript: or about: – in fact, try typing about: in the address bar of your browser and hit “enter” on your keyboard, notice what happens…
In our case where we want to dial a number from within our app we need a way of telling the mobile phone that we want to make a call. There is a scheme for this purpose called tel:. A sample number using this scheme would look like this: “tel:+1-800-555-1234”. If you wanted a number to work around the world you would use an international number which includes the country code.
Implementing this is simple, we could do this within our mobile html5 app like so:
...
call this number
...
Ideally though we would delegate the event and fire a function to call our mythical phone number. To send the url (the “tel” url) to the browser we would write the following:
...
document.location.href = 'tel:+1-800-555-1234';
...
As of PhoneGap 3.6 all schemes are subject to whitelists. This means you have to add the tel scheme to a second whitelist that will allow your app to launch external applications. To do this you need to edit your config.XML to include the following (a mailto example is included):
Go here for more information: Cordova 3.6.0 Whitelist Guide.
Of interest to this topic is getting Android to treat phone numbers (as well as URLs and mailto schemes) as clickable links in text fields. I’ve not tested it but try adding the following to your config.xml.
Additional information on this can be found here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink.
[EDIT: Note that what follows no longer applies but remains here for historical purposes.]
When we run the above code in Android 2.3.6 the phone dialer appears and does so with our number pre-populated ready to be dialed. Unfortunately on iOS 5 this doesn’t happen. A quick review of iOS documentation implies that it should work – so I suppose its just broken.
No need to panic, there is a PhoneGap plugin available which will take care of things. The plugin can be downloaded from here:
Click here to download the iOS Phone Dialer PhoneGap plugin
Its simple to install – just drag and drop the “m” and “h” files on to the classes folder of your xcode project. When you do this a dialog will appear with some options – be sure to click the radio button for copying “…files if needed..”.
Next, update the PhoneGap.plist file to reflect that you are adding a new plugin. The link for downloading the plugin explains the plist values as being “phonedialer > PhoneDialer”… but I think its easier to explain with an image:
The final step is to place the “PhoneDialer.js” javascript file somewhere within the root of your project and then to add it to your index.html file via a script tag.
Now that the Phone Dialer plugin is installed you’ll naturally want to know how to use it:
...
window.plugins.phoneDialer.dial('1-800-555-1234');
...
All in all pretty easy and straight forward, however now you have two methods of dialing a number within a single project. What you want is to use the tel: url scheme in Android and the Phone Dialer plugin in iOS.
Within Sencha Touch we have something called the Ext.is object whose attributes reflect everything that you could possibly want to know about the environment that your mobile app is living within.
For our purposes all we want to know is if we are in iOS or if we are in Android. These two lines provide us the answer:
...
Ext.is.Android // boolean, "true" for android, false otherwise
Ext.is.iOS // boolean, "true" for iOS, false otherwise
...
Thats all we need to impliment phone dialing across the two platforms within our mobile app. Lets build a function that makes use of one of the above (we don’t need both) and we should also give the user a choice in the matter, so the code below includes a message to the user to see if they really do want to suspend the app in favor of the device’s phone dialer:
...
function callSomeone(){
var msg = Ext.Msg.confirm('Please Confirm','Are you sure you want to make a phone call?',
function(r){
if (r == 'yes'){
if (Ext.is.Android){
document.location.href = 'tel:+1-800-555-1234';
} else { // we assume the device is running iOS
window.plugins.phoneDialer.dial('1-800-555-1234');
}
}
});
msg.doComponentLayout();
}
...
All done… I suppose the very last thing to do here is to provide a complete working Sencha Touch example, and some screen captures…
...
Ext.setup({
onReady: function(){
var rootPanel = new Ext.form.FormPanel({
fullscreen: true,
items: [
{
xtype:'button',
text:'Call 1-800-555-1234',
scope:this,
handler: callSomeone
}
],
dockedItems:[
{
xtype:'toolbar',
dock:'top',
title:'Phone Dialer Example'
}
]
}
);
function callSomeone(){
var msg = Ext.Msg.confirm('Please Confirm','Are you sure you want to make a phone call?',
function(r){
if (r == 'yes'){
if (Ext.is.Android){
document.location.href = 'tel:+1-800-555-1234';
} else { // we assume the device is running iOS
window.plugins.phoneDialer.dial('1-800-555-1234');
}
}
}
);
msg.doComponentLayout();
}
}
});
...
From http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/
I'm looking for a all in one QR code solution in which the QR code, when scanned, brings you to a specific app detail page in the app store. A few variables:
when scanned with an iPhone --> go to Apple app store and app detail/installation page
when scanned with an Android --> go to Google play store and app detail/installation page
when scanned with Android and no Google play store --> detect the appropriate app store and open the detail/installation page in that one (for example the Beidu app store)
when no supported app store is detected open a browser (download link) to give the option to install the APK manually
The above should result in a one QR code solution that helps locating the right app in the appropriate stores and that supports iPhone and Android users. It should also support Android users without the Google play store (for example some Chinese users). If no store with the app is detected the QR should redirect you to the APK which can be downloaded and installed manually
Now I've seen solutions in which you have platform specific result (i.e. iPhone opens an app page in Apple store whilst an Android scan opens the Google play store). But I couldn't find any solution where you could have multiple Android app store support or have a backup link when some special conditions are met.
Any help or push in the right direction is very much appreciated!
This will not be possible directly, since QR codes only contains Text data.
So you have to use 3rd party service or own service to redirect into playstores.
Option 1 : Use 3rd party provider
providers :
http://onelink.to/ ( Paid )
https://scanova.io/design-qr-code-generator.html#/create/appstore ( Paid )
https://www.qrdesign.net/en/generate/app-store
http://m.appqr.mobi/ ( Free)
http://www.autofwd.com/ ( Free)
Disadvantages
You might not be able to redirect into other playstores
Not Reliable
Option 2 : Create a service on your Own
Generate QR code to link to your web service.
From your service you need to identify the device/region ( anything you want) and forward the request accordingly.
Following code copied from this stackoverflow question
this is a example.so you can change this however you want.
<?php
**//Handy Code Provided by STEPHENCARR.NET**
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android= stripos($_SERVER['HTTP_USER_AGENT'],"Android");
//check if user is using ipod, iphone or ipad...
if( $iPod || $iPhone || $iPad ){
//we send these people to Apple Store
header('Location: http://www.example.com/'); // <-apple store link here
}else if($Android){
//we send these people to Android Store
header('Location: http://www.example.com/'); // <-android store link here
}
**//Handy Code Provided by STEPHENCARR.NET**
?>
I had the same problem in my server using Express.js (Node.js). To detect whether the operating system is Android, iOS, or any other you can use a third-party library, like Platform.js. In my case I didn't want to bloat my code with yet another library, so I used a simpler solution that seems to work fine:
router.get('/redirecttostores', (req, res) => {
const isIos =
!!req.headers['user-agent'].match(/iPhone/) ||
!!req.headers['user-agent'].match(/iPad/) ||
!!req.headers['user-agent'].match(/iPod/);
const isAndroid = !!req.headers['user-agent'].match(/Android/);
if (isIos) {
return res.redirect(
'https://apps.apple.com/us/app/yourappname/id0123456789'
);
} else if (isAndroid) {
return res.redirect(
'https://play.google.com/store/apps/details?id=com.yourwebsite.yourappname'
);
} else {
return res.redirect('/'); // Neither iOS nor Android!
}
});
You would just need to create a QR Code with this route: yourwebsite.com/redirecttostores.
I finished creating my web app using Django and made the app responsive (using CSS media queries) and customized how it looks on mobile devices. I then created an android app. This app is just a WebView which points to the actual site.
Here is my models.py:
class Blog(models.Model):
user = models.ForeignKey(User)
blogPost = models.CharField(max_length=200)
class BlogComments(models.Model):
user = models.ForeignKey(User)
blog = models.ForeignKey(Blog)
blogComment = models.CharField(max_length=200)
And this is my view which handles BlogComments:
def createCommentView(request):
if request.method=="POST":
if 'blogID' in request.POST:
blogID = request.POST['blogID']
blogPost = Blog.objects.get(id=blogID)
form = CommentForm(request.POST)
if form.is_valid():
newBlogComment = BlogComments(user=request.user, blog=blogPost, blogComment=form.cleaned_data['blogComment'])
newBlogComment.save()
At this point, I want to do something like this:
send blogPost.user a push notification saying "request.user commented on your blog."
How would I do this? Again, the app is just a responsive Django App (created with Django, HTML, CSS, AJAX, JavaScript and Jquery). The Android App is just a basic WebView which points to the responsive website.
Edit:
If you are going to refer me to this:
https://django-gcm.readthedocs.org/en/latest/sending_messages.html
How exactly do I know what the users device name is in the line:
my_phone = get_device_model().objects.get(name='My phone')
Because on the previous page (https://django-gcm.readthedocs.org/en/latest/quickstart.html) it says to register a device, the URL is:
/gcm/v1/device/register/
so when I register a registered users device, how do I know what the device name is?
I'm reading about Flask. Given its tight integration with Jinja2 and WTF-forms, what happens when I start writing a native mobile version of my website? I usually write a bunch of backend API that work independent of the frontend and then code up the frontend using JS. This way, if I have to implement a native mobile app, I can seemlessly use the backend APIs. With Flask's (or some other framework's) tight integration with template engines, how should I design my application?
For example, let us take an example from here, the author advocates that the login function be written like this:
from flask import render_template, flash, redirect
from app import app
from forms import LoginForm
# index view function suppressed for brevity
#app.route('/login', methods = ['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
flash('Login requested for OpenID="' + form.openid.data + '", remember_me=' + str(form.remember_me.data))
return redirect('/index')
return render_template('login.html',
title = 'Sign In',
form = form)
However, when I am building a native Android/iOS app, I'm assuming that the backend should expose a bunch of API calls that validate the input and do the login for you. And given that mobile is agnostic to Jinga2 or some other templating (because everything is implemented native), all this code is useless in the context of native mobile apps. This means, I will have to refactor the "real-world" Flask code to be compatible with a mobile app. Is this the case or am I missing the higher-level point?
My specific question is: What is the design pattern I should follow in Flask to ensure that my site is web and mobile friendly?
I think there are 2 issues here:
Writing a web client that is web and mobile friendly
Designing an application with web and mobile components
Issue 1 would involve a responsive web design that formats the webpage in a manner friendly to both desktop web browsers and mobile web browsers. There are CSS techniques to use different style sheets and templates depending on the browser viewport size. This would be where different jinja2 templates could be used for mobile vs. web clients. Or there are "responsive designs" that adjust according to viewport size.
Issue 2 speaks to how you architect your services and clients. You could do like you said and have a backend API (could be a Flask application or not. Flask-Classy or Flask-Restful are Flask extensions that assist in developing REST API with Flask) independent of any frontend. Then you could code a native mobile app that uses the backend API. And you could code a Flask web application that also uses the backend. There wouldn't be any dependencies between the mobile app and the Flask app. They're just two distinct clients that both access the same backend API.
The example you linked to is creating a monolithic web application. It's an excellent tutorial if that's what you're looking to create. But it wouldn't apply in its entirety if you want a set of services that can be used by both mobile apps and web clients.
Well there is a crude way to go about this issue which I used successfully in my application. So every time a request is made from the web application or the android application I add a field in the request called "device" and set its value to "web" or "android" accordingly.
On the front-end:
<form id="test" action="test" method="get">
<input type="hidden" name="device" value="web"/>
<input type="submit" value="Submit"/>
</form>
Similarly I do the same from my Android Application.
Now at the Flask Server I read the value of this field and handle the request accordingly.
#app.route('/test', methods=['GET'])
def test():
device = request.args.get('device')
if device is "web":
return render_template('test.html', data='Hello Word')
else:
# Return data to Android Application
return json.dumps({'data':'Hello World'})
I am pretty sure there must be a much better way to deal with this, but this one works perfectly fine. Hope it helps :)
#Bahul Jain You can get that using the following code. Not sure is this right way or wrong. But you can check platform in your if condition.
from user_agents import parse
browser = request.user_agent.browser
version = request.user_agent.version and int(request.user_agent.version.split('.')[0])
platform = request.user_agent.platform
uas = request.user_agent.string
print('---browser-{}-----version---{}-'.format(browser, version))
print('---platform-{}-------uas-{}---'.format(platform, version))