10.05.2014
Interessante Apps sprechen i.d.R. mit einem Service
Im Vorfeld: Gedanken zur Authentifizierung
AJAX → JSONP/CORS
Beispiel: Share-Button auf einer Stellenanzeige
<ul class="table-view" ng-if="job">
<li class="table-view-cell">
{{job.title}}
</li>
<li class="table-view-cell">
<p>
<button class="btn-block btn btn-small" ng-click="share()">
<span class="icon-share icon"></span>
<span>Teilen</span>
</button>
</p>
</li>
</ul>
window.App = angular.module('ebmobile', ['ngRoute','ngResource','...'])
App.config(function($routeProvider) {
$routeProvider.when('/job/:jobId', {
templateUrl: 'html/job.html',
controller: 'JobController'
})
})
App.controller('JobController', function($scope, Job, $routeParams) {
$scope.job = null;
Job.get({
id: $routeParams.jobId
}, function(data) {
$scope.job = data;
});
$scope.share = function() {
var message = {
subject: $scope.job.title,
url: $scope.job.url
};
window.socialmessage.send(message);
};
});
SocialMessage.prototype.send = function (message) {
cordova.exec(null, null, "SocialMessage", "send", [message]);
};
// ...
public class SocialMessage extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
// ...
final Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
// ...
cordova.startActivityForResult(this, sendIntent, 0);
}