How to show native popup using Gulp - notifications

I am working on Gulp build process for automation. I have created a Gulp task for creating signed APK of android. Now I want to show a notification popup so that I can come to know my android APK is built.
Is there any way to show native popup in Gulp process?
I have done research and found node-notifier and gulp-notify modules but both are not working for me. Please help
As per posted answer,
I have tried with following, but no help... I am not getting notification. Does it requires Windows Toaster Support... I am using Windows 8.1 Pro.
gulp.task('notifier', function(){
notify('Running from notifier task', 'Everything looks good');
});
function notify(title, message) {
// Load dependencies
var path = require('path');
var notifier = require('node-notifier');
var notifyOptions = {
title: title,
message: message,
//icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
};
// start notifier
notifier.notify(notifyOptions);
}

Try this:
Make sure these are installed by running install once again
Install
npm install path node-notifier --save-dev
Task
gulp.task('notifier', function(){
notify('Running from notifier task', 'Everything looks good');
);
Notifier Function
function notify(title, message) {
// Load dependencies
var path = require('path');
var notifier = require('node-notifier');
var notifyOptions = {
title: title,
message: message,
icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
};
// start notifier
notifier.notify(notifyOptions);
}

This is too late after asking the question, but I thought it's good to record my solutions here.
So there are different commands to show a native popup for different OS.
1. Windows
Use the command msg * <Your_Message_Here>, for example, msg * Hello World.
This popup closes automatically after 1 minute.
2.iOS
Use the command
osascript -e 'tell app \"System Events\" to display dialog \"<Your_Message>\" with title \"<Your_Title>\"'"
and then you can execute these commands using node exec,
var WINDOWS_POPUP = "msg * MESSAGE";
var MAC_POPUP = "osascript -e 'tell app \"System Events\" to display dialog \"MESSAGE\" with title \"SUCCESS\"'";
function execCMD(cmd, cb) {
exec(cmd,
{
cwd: './',
maxBuffer: 2048 * 2048
},
function (err, stdout, stderr) {
plugins.util.log(stdout);
plugins.util.log(stderr);
if (err) {
cb(err);
} else {
cb(null,stdout);
}
});
}
/**
* Rename android apk
*/
gulp.task('copyAPK', function () {
return gulp.src(APK_PATH)
.pipe(plugins.if(args.signedAPK, plugins.rename(APK_NAME)))
.pipe(gulp.dest(releaseDirName + '/Android/'))
.on('end', function () {
plugins.util.log(plugins.util.colors.green('Good Job! Your APK is ready at following location : ') + plugins.util.colors.cyan(releaseDirName + '/Android/' + APK_NAME))
execCMD(WINDOWS_POPUP.replace('MESSAGE', 'Good Job! Your APK is ready at following location : ' + releaseDirName + '/Android/' + APK_NAME), function () {
})
});
});
/**
* Copy generated IPA
*/
gulp.task('copyIPA', function () {
return gulp.src(IPA_PATH)
.pipe(plugins.rename(IPA_NAME))
.pipe(gulp.dest(releaseDirName + '/iOS/'))
.on('end', function () {
plugins.util.log(plugins.util.colors.green('Good Job! Your IPA is ready at following location : ') + plugins.util.colors.cyan(releaseDirName + '/iOS/' + IPA_NAME))
execCMD(MAC_POPUP.replace('MESSAGE', 'Good Job! Your IPA is ready at following location : ' + releaseDirName + '/iOS/' + IPA_NAME), function () {
})
});
})
Hope this will help someone in scripting :).

Related

React Native Fetch Blob/React Native Blob Util Fail in Production but not in Developer time

I am trying to download a pdf generated through an own api that worked normally for me until yesterday, since then it has stopped working without any modification. Reviewing in developer mode through the metro everything seems to work correctly without any problems (I download the pdf normally), but when deploying the application in the playstore it closes unexpectedly, leaving me without knowing why this happens.
First I was using the React Native Fetch Blob, then I used React Native Blob Util hoping it would solve the problem but it keeps happening. Do you guys have any ideas for why does this happen?
The PDF file download this function:
const generarReciboPdf = async (datosDeuda:FormularioScreenParams,formaPago:ReactText,nroCheque?:string) =>{
const{config,fs} = ReactNativeBlobUtil
if (formaPago === 4 && (nroCheque == ""|| undefined)) {
return console.log('debe llenar todos los campos');
}
const { DownloadDir } = fs.dirs;
const token = await AsyncStorage.getItem('token');
let datosDeudaCompleto= {
...datosDeuda,
forma_pago:formaPago,
nro_cheque:nroCheque
}
let url = 'https://sys.arco.com.py/api/appRecibos/generarReciboPdf/'+JSON.stringify(datosDeudaCompleto)
// return console.log(url);
const options = {
fileCache: true,
addAndroidDownloads: {
useDownloadManager: true, // true will use native manager and be shown on notification bar.
notification: true,
mime:'application/pdf',
path: `${DownloadDir}/recibo_${datosDeuda.mes_deuda.replace(/ /g, "")}_${datosDeuda.razon_social.replace(/ /g, "")}.pdf`,
description: 'Downloading.',
},
};
config(options).fetch('GET', url,{Authorization :'Bearer '+token}).then((res) => {
console.log('se imprimio correctamte el pdf');
setErrorPdf(1)
}).catch((error)=>{
console.log(error);
setErrorPdf(-1);
});
}
Also, this error appears in Play Console: "PlayConsole Error Image".
PlayConsole Error Image

Electron + Vue tray wrong icon path

I'm trying to create a Windows applications using Electron and Vue. I want to send the application to the Tray and show an icon to maximize it again when clicked. It works fine in DEV but when I build the app, the Tray icon is not working.
The app it's executing, but when minimized the tray is not showing and there is not option to open it again (need to kill the process).
This is the code I'm trying to use:
app.on("ready", async () => {
if (isDevelopment && !process.env.IS_TEST) {
try {
await installExtension(VUEJS_DEVTOOLS);
} catch (e) {
console.error("Vue Devtools failed to install:", e.toString());
}
}
createWindow();
createTray()
});
const createTray = () => {
const tray = new Tray(resolve(process.resourcesPath, '\\resources\\homeico.ico'))
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show App', click: function () {
app.show()
}
},
{
label: 'Quit', click: function () {
app.isQuiting = true
app.quit()
}
}
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
tray.on('click', () => {
console.log('clicked')
})
}
And in my vue.config.js:
pluginOptions: {
electronBuilder: {
nodeIntegration: true,
builderOptions: {
"extraResources": [
{
"from": "extraResources",
"to": "resources",
"filter": [
"**/*"
]
}
]
}
},
},
The resolve(process.resourcesPath, '\resources\homeico.ico') line is pointing to a existing file, I'm printing this route in the App and I can open it in my Windows Explorer, but when I want to show the Image in the app, I can see next error in the DevTools:
Not allowed to load local resource: file:///C:/Users/mysUser/AppData/Local/Programs/business-config-tool/resources/resources/homeico.ico
The path is accesible, but not in the App.
What's the correct way to configure the path to the icon? there is another path I can configure for assets? I also tried with __dirname and other icon formats (ico, png..)
Thank you.
I ran into the same issue. I searched for a solution for hours, and I finally found one.
This solution is made for app using electron-vue (I personally used this Vue Cli electron plugin). And I tested it on Windows only.
The Tray must be initialised with an icon Path, wich needs be different wether you are running a built version of your app (yarn electron:build), or serving your app (yarn electron:serve).
I am using a function that I called isServeMode, wich basically tells me if I am using the serve mode or the buid mode. Here is what the function looks like :
// utils.js file
const isServeMode = () => {
return process.env.WEBPACK_DEV_SERVER_URL
}
You don't need to create this function, but it might be usefull somewhere else in your app so I suggest you to put it in a file that you can import from anywhere in your app. In my case, I created a utils.js file where I write those functions.
Then, put your tray icon in the public folder, it can not work if you put the icon in the src/assets folder, since we have to access it from the Node environnement and not from Vue. In my case, I put my icon in public/tray/icon.png.
Finally, we can use the electron Tray with Electron vue like this
import { Tray } from "electron"
import path from "path"
import { isServeMode } from "./utils" // Path depends on where you wrote your function
// Some Electron code...
let tray
createTray = () => {
const iconPath = isServeMode()
? path.join(__dirname, "/bundled/tray/icon.png")
: path.join(__dirname, "/tray/icon.png")
tray = new Tray(iconPath)
}
I will soon release a new version of my Unlighter app, wich is an electron-vue app that will include a Tray example. Feel free to take a look at this "real world app example" if you're interested.

Expo BackgroundFetch not working on android when app is terminated

The task gets registered it also works.When in recent apps it works.When gets deleted it stops working!
Expo CLI 3.11.3 environment info:
System:
OS: Windows 10
Binaries:
Yarn: 1.21.0 - C:\Users\Steve\AppData\Roaming\npm\yarn.CMD
npm: 6.9.0 - E:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5900203
SDK version : 36.0.0
Standalone app on android 7
Just to confirm I was right I went into my apps background in my setting in my phone,I can see the app is in background progress.As soon as I remove it from recent apps it gets gone from the background progress too.So everything is as I described and no doubts about it.I also have used:
stopOnTerminate: false,
But it doesn’t do anything.
Here’s a function that does register the tasks and everything:
import * as BackgroundFetch from 'expo-background-fetch';
import * as TaskManager from 'expo-task-manager';
export async function registerFetchTask(taskName, jobCallback, interval) {
TaskManager.defineTask(taskName, jobCallback);
const status = await BackgroundFetch.getStatusAsync();
switch (status) {
case BackgroundFetch.Status.Restricted:
case BackgroundFetch.Status.Denied:
console.log("Background execution is disabled");
return;
default: {
console.log("Background execution allowed");
let tasks = await TaskManager.getRegisteredTasksAsync();
if (tasks.find(f => f.taskName === taskName) == null) {
console.log("Registering task");
await BackgroundFetch.registerTaskAsync(taskName,{
minimumInterval: 60,
stopOnTerminate: false,
startOnBoot: true,
});
tasks = await TaskManager.getRegisteredTasksAsync();
console.log("Registered tasks", tasks);
} else {
console.log(`Task ${taskName} already registered, skipping`);
}
console.log("Setting interval to", interval);
await BackgroundFetch.setMinimumIntervalAsync(interval);
}
}
}
Inside app.js I call:
registerFetchTask('wow',()=>{
fetchServer('/test',{});
console.log('WOWWW HIIIIIIIII YGNNNNNN');
},5);
The fetchServer will add things to my database on my laptop.So I can see if the app is running the task I’m getting new rows in the database.

titanium appcelerator cloudpush tray notification not showing

Iam developing an application that uses push notifications.
Iam using ti.cloudpush module 3.2X and titanium sdk 3.2X
When i tries to recieve notification it deos not showing on tray.
I can read message inside application but it is not creating on notification tray.
here is my sample code
var CloudPush = require('ti.cloudpush');
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.showTrayNotification = true;
CloudPush.focusAppOnPush = false;
CloudPush.retrieveDeviceToken({
success : function deviceTokenSuccess(e) {
alert('Device Token: ' + e.deviceToken);
deviceToken = e.deviceToken;
},
error : function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
CloudPush.addEventListener('callback', function(evt) {
alert(evt.payload);
//alert(JSON.stringify(evt.payload));
});
CloudPush.addEventListener('trayClickLaunchedApp', function(evt) {
Ti.API.info('Tray Click Launched App (app was not running)');
});
CloudPush.addEventListener('trayClickFocusedApp', function(evt) {
Ti.API.info('Tray Click Focused App (app was already running)');
});
Thanks in advance
Assuming you have set up the PushNotifications.subscribe correctly the default properties of this module are used until you set a property for the first time.
Because the properties are persisted to the device settings (via Titanium.App.Properties), the most recent value you set will always be used.
Do a Build > Clean to make sure you have not overwritten one of these properties by accident.
Then double check what they are set to with quick logging check -
Ti.API.log(Ti.App.Properties.getString('oneofthecloudproperties');
You should then be able to see if it's an issue with the subscribe event or how you have set the push notification properties.

Push notification with Appcelerator (ACS) on Android

I'm trying to implement push notification with Appcelerator Cloud Service on Android But I have some issues ... tiapp.xml here :
<sdk-version>2.0.2.GA</sdk-version>
<modules>
<module platform="commonjs" version="2.0.5">ti.cloud</module>
<module platform="android" version="2.0.5">ti.cloudpush</module>
</modules>
Android runtime v8 and ti.cloudpush included, here is my app.js file
var win = Ti.UI.createWindow({
backgroundColor:'#ccc',
title:'Android Cloud Push Notification'
})
var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
var deviceToken;
var Cloud = require('ti.cloud');
Cloud.debug = true;
var submit = Ti.UI.createButton({
title : 'Register For Push Notification',
color:'#000',
height : 53,
width : 200,
top : 100,
});
win.add(submit);
submit.addEventListener('click', function(e) {
CloudPush.retrieveDeviceToken({
success: function deviceTokenSuccess(e) {
alert('Device Token: ' + e.deviceToken);
deviceToken = e.deviceToken
loginDefault();
},
error: function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
});
function defaultSubscribe(){
Cloud.PushNotifications.subscribe({
channel: 'chanel',
device_token: deviceToken,
type: 'android'
}, function (e){
if (e.success) {
alert('Subscribed for Push Notification!');
}else{
alert('Error:' +((e.error && e.message) || JSON.stringify(e)));
}
});
}
function loginDefault(e){
//Create a Default User in Cloud Console, and login
Cloud.Users.login({
login: 'android',
password: 'android'
}, function (e) {
if (e.success) {
alert("login success");
defaultSubscribe();
} else {
alert('Error: ' +((e.error && e.message) || JSON.stringify(e)));
}
});
}
CloudPush.addEventListener('callback', function (evt) {
//alert(evt);
alert(evt.payload);
});
CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
//Ti.API.info('Tray Click Launched App (app was not running)');
alert('Tray Click Launched App (app was not running');
});
CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
//Ti.API.info('Tray Click Focused App (app was already running)');
alert('Tray Click Focused App (app was already running)');
});
win.open();
I had the user android / android in the Appcelerator cloud console for the development mode. Launched my app to my device with debogage mode
On the app : Just click on the button "register for push notification" and see 3 alerts
1) Device Token : " all numbers "
2) login success
3) Subscribed for Push Notification!
On the Appcelerator Cloud console :
Logs -> see login & subscribe, opened it and everything's ok
Push Notifications -> 1 Android clients subscribed to push notifications. And send one throught push notifications with alert & title
And nothing appears at all ... try reboot, try to turn the app off and send another one, nothing.
I was using a device (LG OPTIMUS ONE) with android 2.2.1 with internet on it (wifi). So, I tried with another phone (SAMSUNG GALAXY S2) 3.3.2 with internet on it (wifi)
And the only change is in the cloud console :
Push Notifications -> 2 Android clients subscribed to push notifications.
But it is the same, no notification appears.
Please, I really need help for this, I succeed with iOS in 2 days and I do not understand what is the big deal here ?
I don't think I need to register with Google C2DM for using ACS.
ACS use MQTT protocol for sending push.
(I followed this step by step tut : http://www.titaniumtutorial.com/2012/06/appcelerator-cloud-push-notification-in.html)
Have you already done one project with push notification on Android & Ti ?
I checked my settings and everything is fine.
But, because I'm desperate, I also register to C2DM and nothing better, I guess I have to wait a bit more before testing.
I use the upush module in the Marketplace, took me 10 minutes to gtet it up and running, saved me loads of time.
Have you registered with Google C2DM? You need to fill out the form at https://developers.google.com/android/c2dm/signup to send notifications to the device. Make sure you have your correct App ID in the Appcelerator Cloud Settings.