alert() not working with PhoneGap on Windows Phone - windows-phone-7

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.

Related

Dialog on web version of Outlook does not send messages between parent and child

I have an add-in that opens a dialog box using Office.context.ui.displayDialogAsync() with displayInIframe: true
I compose an email and open the add-in. Using the add-in I select the files I wish to attach to the email. On the desktop Outlook app this works perfectly.
On the web version nothing happens. I can't see any communication between the dialog and host page when using Office.context.ui.messageParent() or Office.Dialog.messageChild()
The frontend in the dialog sends a message with the file blob to the parent function in the functionfile. The functionfile should then call addFileAttachmentFromBase64Async() when it receives this message but on the web version I can't see any evidence of this.
I've read it could be to the urls in the in the manifest.xml. Here is ours:
<AppDomains>
<AppDomain>https://outlook.office.com</AppDomain>
<AppDomain>https://outlook.live.com</AppDomain>
<AppDomain>https://localhost:44312</AppDomain>
<AppDomain>https://*.{company}.cloud</AppDomain>
<AppDomain>https://localhost:3001</AppDomain>
</AppDomains>
And here is the simplified section of code that opens the dialog:
Office.context.ui.displayDialogAsync(url, { height: 60, width: 60, displayInIframe: true }, asyncResult => {
if (handleError(asyncResult)) return;
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
const promises = [];
{working business logic}
Promise.all(promises).then(values => {
{working business logic}
event.completed();
});
});
Other issues we have in the web version that might be releavent:
The 'X' close button in the top right of the dialog box does not work. Neither will calls to Office.context.ui.closeContainer() or Office.Dialog.close()
If we set displayInIframe: false then the add-in will immediately close itself upon opening unless we throttle our internet connect. But even when throttling the attaching email process does not work. If I remove the <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" crossorigin></script> script in the .html then it no longer crashes (but naturally the app needs that)
I have tested this on both Edge and Chrome and they both have this issue. I have not tested on any other browsers
Again, the app works correctly and as expected on the Outlook desktop app. Any help or suggests are appreciated. Thanks.
Just remove the event.completed() call from the callback.

Notification from electron shows electron.app.Electron

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

Alert is not visible in nativescript ios after autocomplete usage

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.

Closing Android Activity opened from Forms.Context.StartActivity

I am working on facebook authentication in a Xamarin forms app and want to use "native" login on each device.
The Facebook SDK (by Xamarin) is not designed for forms since it requires passing in an Android activity that implements some specific interfaces.
However; I was able to get the UI to display using a custom page renderer and then in that renderer calling StartActitivty with an activity that uses the exact implementation described in the Facebook SDK getting started. https://components.xamarin.com/view/facebookandroid
So far everything works perfect. The android app starts, xamarin forms kicks in, the custom page renderer is loaded the login android activity starts and the user logs in with facebook and we get to the console.writeline below.
So, how do I dismiss this intent or otherwise get back to xamarin forms?
Do I:
Dismiss this intent? - if so then what?
Inject something to "reset" the main page?
Other?
public void OnCompleted (Xamarin.Facebook.Model.IGraphUser user, Response response)
{
//TODO: show user details with welcome and button that takes them to main app.
//TODO: switch back to xam forms from here on out.
//TODO: figure out how to change the `main` activity to xam forms.
// 'Me' request callback
if (user != null) {
//How do I get back to Xamarin forms from here?
Console.WriteLine ("GOT USER: " + user.Name);
} else {
Console.WriteLine ("Failed to get 'me'!");
}
}
You should call Finish();
Anyway, if you want to see exactly how I did it, you can check it here:
https://github.com/IdoTene/XamarinFormsNativeFacebook

Show notifications when app is closed

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

Resources