PhoneGap Build for windows phone and other platforms - android

I have started a project in phonegap for windows phone, and created a login form. Backend I have written some c# code for perform some api methods and check login.
And I have build the phonegap and got output file for all the platform. Whether is it compatible with all other platform than windows ?

I'm afraid your c# code will not be compatible with other platforms. You either need to write Phonegap plugins for each platform or write JavaScript to check login.
Depending on your situation, Phonegap has APIs for accessing the device's filesystem or making use of browser storage (Web SQL database).
See the Phonegap API for more info

For working with cross platform, I have created a web service and called the method of web service with ajax call,
If the webservice hosted in any other domain you should use
$.mobile.allowCrossDomainPages = true;
$.support.cors = true;
Refer more :- http://jquerymobile.com/test/docs/pages/phonegap.html

Related

App crashes when opening a ftp link in browser, with Device.OpenUri(uri), in Xamarin

I'm currently implementing a part of Xamarin app, which needs to open links in browser, after clicking the URL. I need to add support for http, https, ftp and ftps.
Our app uses .NET Standard 1.6 (Thus, can't use WebClient Class or FtpWebRequest class).
Device.OpenUri(uri) works fine with http and https in both iOS and Android. But only works with iOS for ftp links. With Android, app crashes with ftp links.
For file links with ftp, I managed to download files using FluentFTP (version="23.1.0").
Now I need to add support for ftp links with directory structures, to open that directory structure in the browser. (Like the default behavior of the Chrome browser)
I have tried:
Device.OpenUri(uri),
By creating an intent (Not working for ftp)
What you should be doing is something like below:
Create an interface for your Dependency Service for Android.
public interface IWebFTPClient<T>
{
Task<T> MakeFtpRequestAsync(); //Add Parameters if needed
}
Then call the depedency service method :
DependencyService.Get<IWebFTPClient<YourType>>().MakeFtpRequestAsync();
Note: Above code is an example piece and may need changes as per your needs
Since FtpWebRequest is available in native android, use it something like follows:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
Good luck
Revert if you have queries

NodeJS detect either the client(mobile) is a browser or an application?

I have developed a simple REST api using NODE and EXPRESS. And I already have a web-app(browser) and a native mobile application.
Now I need to check if the incoming request is from web-browser or from native application.
I have successfully detected the device for incoming request coming from browser via USER-AGENT.
I will suggest using the Host header.
For example:
If your web application is hosted at example.com then all requests will have Host header set to example.com.
In your mobile application, you can manually set all request headers to have a different Host header like Host:app.example.com.
A good practice to have limited set of hostnames that accepted by the server.
Make sure you do not tight any security logic to that header. Every HTTP client can fake/override that value.
window.navigator.standalone for iOS, and window.matchMedia('(display-mode: standalone)').matches for Android to detect this:
isInWebAppiOS = (window.navigator.standalone == true);
isInWebAppChrome = (window.matchMedia('(display-mode: standalone)').matches);
Set a cookie for each to pass to the server.
References
Optimized Presentation of XML Content | Introduction
Android 8.0 Compatibility Definition  |  Android Open Source Project
Issues - chromium - An open-source project to help move the web forward. - Monorail
143578 – Chrome: XMLHttpRequest executed in UIWebView encodes valid query string characters
Browser Shredders: iOS UIWebView baseURL
iOS - Best Practices for Opening a Web Page Within an App - Outbrain Developer Center
CWE - CWE-749: Exposed Dangerous Method or Function (2.11)
Attack Surface Extended by URL Schemes (pdf)
Implementing XSLT into our iOS Apps | The Distance, York
How to transform xml with xslt and display it in Android webview
XSLT in a UIWebView using iOS SDK 4.2
detect ipad/iphone webview via javascript
is-webview

Designing a Flask application with mobile in mind?

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))

Embarcadero HTML5builder android MNotification how to use (code)

I am using Embarcadero's HTML5Builder for Android server mobile apps development.
How can i use Mobile Hardware components, like: MNotification.
i need some useful code to use MNotification.
Just give a value to the Message property from the Form Designer, and call ComponentNameNotification() from a JavaScript event, where ComponentName is the name of the MNotification component.
For example:
function MButton1JSClick($sender, $params)
{
?>
//begin js
MNotification1Notification();
//end
<?php
}
Note that hardware components only work inside PhoneGap. The notification will show in an application generated with the Mobile Deployment wizard, but not in a web browser.
SO WHAT TO DO:
Download the SDK ADT Bundle for Windows
http://developer.android.com/sdk/index.html
Download PhoneGap
http://phonegap.com/download
And use this instructions:
1) http://www.youtube.com/watch?v=lVjCMXQGS_w
2) http://www.youtube.com/watch?v=HO_59WXg33g
Thank's to all who trying to help me!

Sencha Touch 2.1 native (android) app not getting json from remote (it works on PC)

I created my first Sencha touch 2 app by watching this video (http://youtu.be/5F7Gx0-W-M4) and it has a store page structured like this:
Ext.define('FirstApp.store.Places',{
extend:'Ext.data.Store',
config:{
autoLoad:true,
model:'FirstApp.model.Place',
proxy:{
type:'ajax',
url:'https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyCFWZSKDslql5GZR0OJlVcgoQJP1UKgZ5U',
reader:{
type:'json',
rootProperty:'results'
}
}
}
})
The after-build (after running "sencha app build native") package work very well on my MAC (all browsers) but the generated app (i am running it on my nexus phone) works but doesn't collect any data from the google maps json.
Any help would be appreciated
The example you are referring is using google map's place search API. You can not use this API when you build the app for mobile phone with proxy set to ajax . Basically, you can not use any resource that is outside your domain. Like if your site is at yourdomain.com and there is someotherdomain.com, then you can't make ajax request to this someotherdomain.com from yourdomain.com unless that domain allows you to. In this case, your mobile app is not having any domain. You are just loading a page inside webview.
The reason is, ajax will not be able to load cross-origin resources. App build works on browsers because I believe you're using chrome with --disable-web-security flag. To work with CORS you need to use JsonP proxy. It's the only way if you're packaging for mobile app. If in a case, you own the server ( not in this context though ) then you can allow CORS by setting appropriate headers like
Access-Control-Allow-Origin: *
or
Access-Control-Allow-Origin: http://yourdomain.com/resource
Try setting proxy to JsonP .

Categories

Resources