I am developing an electron + ionic application and using electron notifications. I have packaged the application using electron builder and installed it on my PC. The notification comes with the text 'electron.app.Electron' instead of the app name from the package. This is the sample notification code:
click: function() {
const notification = {
title: 'Basic Notification',
body: 'Notification from the Main process',
icon:path.join(__dirname, 'favicon.ico'),
silent : false
}
new Notification(notification).show()
}
How can I get the notification to display the app name instead of electron.app.Electron? When I used the tray displayBalloon option instead, it displayed the name correctly but unfortunately, it's not supported in Mac and I had to shift to using electron notification.
Please have a look at these two answers to more or less the same question:
Electron app notification states the app sending notification is electron.app.<App Name> even after packaging
how can you overwrite or remove the signature “electron.app.Electron” from the desktop notification
Basically, you need to call app.setAppUserModelId() on Windows:
if (process.platform === 'win32')
{
app.setAppUserModelId(app.name);
}
Related
I'm attempting to configure AppCenter.Distribute for in-app updates within my Xamarin Android app. Here is the very basic setup code, which I have in my main launcher activity's OnCreate method (AFTER the base.OnCreate call):
AppCenter.Start (Resources.GetString (Resource.String.appcenter_app_secret), typeof (Analytics), typeof (Crashes), typeof (Distribute));
I was able to get the in-app updates to supposedly initialize. When I first install and open the app, it shows a browser window for one second that says "In-app updates enabled! Returning to app in 1...", then it redirects back to my app. Unfortunately, when I then bump the version name and code and distribute a new build, I don't get a dialog within the app prompting me to update to the new version.
I even tried handling the Distribute.ReleaseAvailable action and showing a custom dialog, and that action isn't invoked either:
Distribute.ReleaseAvailable = OnReleaseAvailable;// Called before AppCenter.Start
private bool OnReleaseAvailable(ReleaseDetails releaseDetails)
{
// Show custom dialog.
Droid.ApplicationContext.Activity.CustomDialogBuilder().Show(new NotificationArgs
{
Title = "New update available!",
Message = "A new version of RPR Mobile, {0} ({1}) is available. Release notes: {2}"
.WithFormat(releaseDetails.ShortVersion, releaseDetails.Version, releaseDetails.ReleaseNotes),
PositiveButtonText = "Update",
PositiveAction = () =>
{
// Notify SDK that user selected to update...
Distribute.NotifyUpdateAction(UpdateAction.Update);
},
HideNegativeButton = releaseDetails.MandatoryUpdate,
NegativeButtonText = "Postpone Update",
NegativeAction = () =>
{
// Notify SDK that user selected to postpone (for 1 day)...
// Note that this method call is ignored by the SDK if the update is mandatory.
Distribute.NotifyUpdateAction(UpdateAction.Postpone);
}
});
// Return true if you are using your own dialog, false otherwise.
return true;
}
I'm wondering what I'm missing. Some questions that may or may not be relevant...
Does it matter whether the AppCenter.Start code executes before or after the base.OnCreate call?
Does it matter whether the activity that AppCenter.Start is called from is running or finished? Because in our case, the main launcher is just a splash screen that closes after a couple seconds.
Is the App Center SDK supposed to poll every few seconds for an update? Or does it check only when opening and closing activities?
It turns out that you have to close and relaunch your app for it to check for new updates. The documentation could be more clear on this...
I am working on a nativescript app for android and ios in which I have used REST APIs to store/get data in JSON format.
Based on JSON result from APIs sometime I need to show alert to the user.
It was working fine with Nativescript 4.1 but since I have upgraded to 4.2 app is unable to show alert boxs in ios. It shows the blank page and shows the following error.
(UIKitCore) Warning: Attempt to present <UIAlertController: 0x7fb5834eb000> on <UIViewControllerImpl: 0x7fb58659a670> whose view is not in the window hierarchy!
I have suspected that I am calling alert too early so I have tried to add timeout before alert but still it's the same.
if (result.status === 'E') {
setTimeout(function () {
const alertOptions = { title: 'Error', message: result.errMsg, okButtonText: 'OK', cancelable: false };
dialogs.alert(alertOptions).then(() => {
resolve('Error');
});
}, 700);
Points to note here is I am using nativescript-autocomplete component in one of my tabs. and this problem occurs only when user searches something using that component.
So it could be something related to that component.May be when autocomplete closes the modal, app looses the parent reference ?
Found an interim solution for now.
nativescript-fancyalert works like a charm. Will stick with that for sometime.
It is based on SCLAlertView for ios.
I am developing apple watch companion app in for xamarin forms project. There when iPhone app or parent app is in background I am not able to get continuous data from parent app to my companion app. I used below peace of code inside the app delegate but that also get stop sending data after certain time due to iOS backgrounding time restriction of 10 min.
Can some body suggest what will be the proper way to get data continuously from the parent app to companion app even when parent app is in background.
public override void DidEnterBackground(UIApplication application)
{
var taskID = UIApplication.SharedApplication.BeginBackgroundTask(
()=> {
if(SessionManager.session.Paired && SessionManager.session.Reachable)
{
Console.WriteLine("Start the background task.......");
timer = NSTimer.CreateRepeatingScheduledTimer(20, UpdateUserInterface);
UpdateUserInterface(timer);
Console.WriteLine("Running out of time to complete you background task!");
UIApplication.SharedApplication.EndBackgroundTask(taskID);
}
});
}
I'm having problems with notifications in my app.
I've seen some pages reference to the AlarmAPI in Firefox OS and how to handle notifications:
https://developer.mozilla.org/en-US/docs/WebAPI/Alarm
https://developer.mozilla.org/en-US/Apps/Developing/Control_the_display/Using_Alarms_to_notify_users
http://rootslabs.net/blog/199-firefox-os-dev-tips-2
The code is basically the same in both cases and it only works when my app is open or in background. If I close my app it doesn't show notifications. I've tested the example app from the second link and it works when the app is closed.
What could the problem be and how can I fix it?
Thanks.
you must use navigator.mozSetMessageHandler()
https://developer.mozilla.org/en-US/docs/Web/API/Navigator.mozSetMessageHandler
if(navigator.mozSetMessageHandler) {
navigator.mozSetMessageHandler("alarm", function (alarm) {
// only launch a notification if the Alarm is of the right type for this app
if(alarm.data.task) {
// Create a notification when the alarm is due
new Notification("Your task " + alarm.data.task + " is now due!");
updateNotified(alarm.data.task);
}
});
}
I'm trying out PhoneGap 1.4 on Windows Phone 7.5 using jQuery mobile (1.0.1.).
Basic navigation is working, unfortuantely I can't seem to get alerts working. Neither alert("string); nor PhoneGap's navigator.notification.alert(message, alertCallback, [title], [buttonName]); get me any response. The PhoneGap test message is being displayed fine. This is the way I try to call it:
function init()
{
document.addEventListener("deviceready",onDeviceReady,false);
}
function onDeviceReady()
{
document.getElementById("welcomeMsg").innerHTML += "PhoneGap is ready!";
alert('test');
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}
See this Google Groups discussion.
In short, Windows Phone 7 IE9 web browser doesn't support alerts, and instead you must use the PhoneGap Notification API, like this:
navigator.notification.alert("Message", callBackMethod, "Title", "Button Text");
For further information, see the PhoneGap Notification API.