Android Facebook SDK - part of the post remains not shown - android

I'm using phonegap-build / FacebookConnect
Everything works correctly but when I put some post using Android app on the Facebook wall, most of the text remains not shown. There is not even "see more" link at the end of the part of the post. At the half of the second sentence of "description" everything breaks.
The JS function that I'm using for this Android app:
function facebookWallPost() {
console.log('Debug 1');
var params = {
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (TCP/IP) to serve billions of users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic, wireless and optical networking technologies. The Internet carries an extensive range of information resources and services, such as the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support email.'
};
console.log(params);
FB.ui(params, function(obj) { console.log(obj);});
}
The whole script and an example can be seen here ...
Do I need to change data structure and post params as JSON?
Thanks in advance. I appreciate any help...

Related

Question about mobile app scheme deep linking

I have the Medium app install on my iPhone.
When doing a search on Google Chrome app, when I clicks on a medium.com link in the search results, it open my Medium app.
How can this happen? How can Google Chrome can interpret https://medium.com to medium://?
So the feature in particular you are referring to is Universal Links and requires both server side and client side modifications.
On the server side / website you need to add an AASA (Apple App Site Association) file. This file is simply a JSON file that contains the specific applinks urls for the corresponding app identifier. A sample is shown below.
{
"applinks": {
"apps": [],
"details": [{
"appID": "ABCDEBBQ.com.medium.ios",
"paths": ["*"]
}]
}
}
If you note the paths key in the JSON above you will see that there is a star or wildcard symbol. This simply means open any URL on my websites’ domain. For example www.medium.com/topposts will open in the medium iOS app. It should be noted that you can explicitly define your paths to either include or exclude.
On the client side (Xcode) you’ve gotta setup the associated domains capability inside of your application and specify the applinks service for your domain in this case www.medium.com
Lastly you’ve gotta add the capability to your application identifier inside of the developer portal.
After all of this configuration is completed you should now have a ‘link’ between your website and application.
Apple handles all of this logic internally in iOS and since it’s closed source I cannot give you the exact implementation details but the just of it is that when you visit the domain (medium.com) on your iOS device it downloads the AASA file from the webserver (the AASA file must be hosted on a secure server and can only be downloaded over HTTPS) and the operating system then checks whether there is a corresponding application on the device that matches the appId specified in the AASA file. If both the paths and appIds match it then launches the medium iOS application on the phone.
That’s how it works. I hope that I’ve articulated it well enough.

Dealing with data changes in native app

My background is web development. Last year we started writing a native app with React native and the app is now live and kicking. Everything is working fine, but I'm wondering about the following problem.
With web development - if you have to add a new feature. You just go add it on the server, make modifications to the database, to the client/page and the next time a user visits your website the user can work with your new feature (mostly). But how do you do this on the native side when the user doesn't necessarily always run the latest version of the app?
Following situation.
We have user comments and system generated comments. We didn't account for the fact that we need to translate the system comments in different languages. So lets say that we have this structure for user comment:
{
id: "aqdfkah12"
author: {name: "xxx"}
text: 'my comment text"
}
and this would be a system comment
{
id: "aqdfkah13"
author: {name: "system"}
text: "The task was created."
}
In the new version of the app - instead of directly writing the translated string in the database - we are going to save a language constant.
{
id: "aqdfkah13"
author: {name: "system"}
text: {languageConstant: 'task_created'}
}
This works. In the new version we account for the fact that old comments had a string in the text field and in the new version we have a json. So we are able to show the old comments as they are and have the new system comments translated to the user's locale.
This works with the new version, but the app crashes on previous versions, because the code expected to have a string and now we are trying to directly output a json object and that is not valid.
We cannot possibly predict the database structure of the app for the future. We are always going to change things as the app evolves.
How do you deal with such situations?

Call phone number phonegap

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/

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

How to retrieve completed payment details on android

On android we have access to the following:
// Get the confirmation data
PaymentConfirmation confirmation = data.getParcelableExtra( PaymentActivity.EXTRA_RESULT_CONFIRMATION );
Which when converted to a JSON object, gives us details about the payment, such as completed, the sdk version in use etc. However it does not contain the currency code, short description and amount variables that are available on iOS.
On iOS you can retrieve the currency code like this for example:
- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment
{
NSString *currencyCode = completedPayment.currencyCode;
}
How can one get access to these variables on Android? Honestly, the discrepancies between the PayPal Android & iOS SDK's are starting to get on my nerves. I don't mind a little discrepancy, but please at least document them.
The PayPal iOS/Android SDK documentation is some of the worst documentation I have seen in my life. Not trying to upset anyone or be rude, it's just starting to get tiresome to keep having to ask questions on stackoverflow about things that should be documented.
Hoping for a quick answer.
I'm using the latest version of the PayPal SDK for both Android and iOS.
Thanks
The confirmation object includes the payment. To get JSON representation of the payment info:
confirm.getPayment().toJSONObject().toString(3)
This will provide the info you are looking for:
{
"amount": "2.85",
"short_description": "Awesome Sauce",
"intent": "sale",
"currency_code": "USD"
}
We will add this to the SampleApp for better clarity.

Categories

Resources