Skip to content

Instantly share code, notes, and snippets.

@manumaticx
Last active January 25, 2016 13:32
Show Gist options
  • Save manumaticx/11400523 to your computer and use it in GitHub Desktop.
Save manumaticx/11400523 to your computer and use it in GitHub Desktop.
Normalized User Notifications
/*
* This is how I notify users about errors, confirmations etc.
* e.g.: "Wrong password", "Registration complete", ...
*
*/
module.exports = (function(){
var notification,
OS_IOS = 'iPhone OS' === Ti.Platform.name,
OS_ANDROID = 'android' === Ti.Platform.name;
if (OS_ANDROID){
notification = require('de.manumaticx.crouton');
}
if (OS_IOS){
notification = require('de.marcelpociot.mwkprogress');
}
function confirm(message){
OS_IOS && notification.showSuccessMessage(message);
OS_ANDROID && notification.showText(message, notification.STYLE_CONFIRM);
}
function alert(message){
OS_IOS && notification.showErrorMessage(message);
OS_ANDROID && notification.showText(message, notification.STYLE_ALERT);
}
function info(message){
OS_IOS && notification.showMessageWithColor({
message: message,
color: '#005bd1'
});
OS_ANDROID && notification.showText(message, notification.STYLE_INFO);
}
return {
confirm: confirm,
alert: alert,
info: info
};
}());
@manumaticx
Copy link
Author

var notification = require('notification');

notification.alert("Please check your internet connection and try again.");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment