navigator.notification.alert iOS - javascript

My alert on ios project doesn't work. I'm using ionic and angularjs to develop my app.
The problem is that when alert is show, the title is "index.html". Actually I call alert like this:
alert("aaa");
I read that cordova allows to change title, using navigator.notification.alert. But the alert is not show when I call it.
I call alert as below:
.controller('MyCtrl',function(){
$scope.myfunction = function(){
var success = function(data){
//do something
};
var failure = function(message){
navigator.notification.alert(
"This is my Alert text!",
callBackFunctionB, // Specify a function to be called
'Alert Title',
"OK"
);
};
function callBackFunctionB(){
console.log('ok');
}
}
});
I add plugin and add key in infoplist following instructions in phonegap documentation.
Anyone can help me?

I tried to remove plugin and reinstall it and now it work.

Related

Cannot send information to dialog box; "Office.context.ui.addHandlerAync is not a function"

I am trying to send information to a dialog box in an Outlook web-add in.
var url = window.location.origin+'/dialog.html'
var dialog
Office.context.ui.displayDialogAsync(url2,
function (asyncResult) {
dialog = asyncResult.value;
dialog.messageChild('message')
});
Which opens a dialog box and tries to send information to the dialog which has this Javascript:
Office.onReady().then(()=> {
Office.context.ui.addHandlerAsync(
Office.EventType.DialogParentMessageReceived,
onMessageFromParent);
});
function onMessageFromParent(arg){
console.log(arg.message)
document.getElementById('ID').style.display = 'none';
}
However, that just gives me the error:
TypeError: Office.context.ui.addHandlerAsync is not a function
When I run console.log(Office.context.ui), I get:
OSF.DDA.UI.ParentUI
[[Prototype]]:Object
closeContainer:function(){ … }
displayDialogAsync:function(){ … }
openBrowserWindow:function(){ … }
__proto__:Object
As you can see, there is not a addHandlerAync function within Office.context.ui but the Microsoft documentation says to use it.
What is going wrong here? Thanks
I look at your add-in. Its taskpane.html is not completed yet and the JavaScript is not included. However, I manually load the dialog page in the debugger and I confirm that your code in dialogbox.html is working. I can see Office.context.ui.addHandlerAsync is available in the Office.onReady handler. Would you like to fix your add-in and double check it's working?

Cordova-dialogs-plugin not showing when I run my code on emulator

I'm making an application and part of it requires a dialog to pop-up after my camera has taken the picture. To be more specific it's a confirmation dialog using navigator.notification.confirm
I'm stuck at the dialog part. It isn't showing up after my camera takes the picture
I tried calling the function initDialog(); in my cameraSuccess() function but it doesn't really do much. I've managed to put in just a regular alert() code in and it worked, so the problem is definitely in how I'm trying to use the dialog plugin. I even tried using innerHTML to create a button that once clicked leads to dialogs but to no avail.
//camera code
function cameraSuccess(imageData){
document.getElementById("camera-picture").src= imageData;
initDialog();
}
function cameraError(error){
alert(error);
}
function myCameraInit(){
console.log(navigator.camera);
var cameraOptions = {
quality: 100,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.CAMERA
};
navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);
}
//dialogs code
function initDialog() {
var message = "Proceed with analysing photo?";
var title = "Confirmation";
var buttonLabels = "Ok, got it.";
navigator.notification.confirm(message, confirmCallback, title, buttonLabels)
}
The output I'm expecting is for the dialog to pop-up after my camera takes the picture. The output I'm getting is the dialog not popping up.
If the HTML code is needed please tell me and I will update the question.
You need to wait for the device to be ready when it's in the foreground again.
document.addEventListener('deviceready', function() {
navigator.notification.confirm(message, confirmCallback, title, buttonLabels);
}, false);
If the above does not work, I would check your console for any errors.

Notify users when the browser is minimized

I am using AngularJS & SPring. I need to find a way to notify the users even when the user has minimized the application browser window OR IS there any other better option to notify the users based on a batch job.
Maybe you are looking for something like Browser Desktop Notification.
I just found this LINK and maybe this could help you.
angular.module('app', ['notifyme']). controller('appcontroller', function($scope, NotifyMe) {
$scope.nofity = function(){
var title = "I'm from Angular ?";
var body = 'This is a simple demo for the notification API Angular Service';
NotifyMe.launch(title, {
body: body,
onclick:function(){
console.log("On Click Triggered");
},
onerror:function(){
console.log("On Error Triggered");
},
onclose:function(){
console.log("On Close Triggered");
}
});
};
});
Working Fiddle from the link:

How to update UI from Async function in javascript?

I am developing sharepoint hosted app in sharepoint 2013. I am using following function to upload file in sharepoint.
self.UploadFile = function () {
// Suppose my business logic goes here
appWebContext.load(files);
appWebContext.executeQueryAsync(
function () {
alert("All files are uploaded.");
SP.UI.ModalDialog.commonModalDialogClose();
//SP.UI.ModalDialog.commonModalDialogClose();
//window.close();
},
function (error, errorMes) {
//SP.UI.ModalDialog.commonModalDialogClose();
//$("#btnMigrate").val("Migrate Class");
//$("#btnMigrate").removeAttr("disabled");
//alert(errorMes.get_message());
alert("Oooooops... it looks like something went wrong uploading your file.");
});
};
The above code works fine. It shows the messsage 'All files are uploaded'. Then it gives error on SP.UI.ModalDialog.commonModalDialogClose(); In above code when I call SP.UI.ModalDialog.commonModalDialogClose(); in appWebContext.executeQueryAsync function I get the error 'Javascript runtime error : Function is undefined'. Can anyone please tell me how to update UI from async function in javascript? Can you please provide me any code or link ?
The SP.UI.ModalDialog.commonModalDialogClose() method takes a "result" as a parameter.
SP.UI.ModalDialog.commonModalDialogClose(1,'Yay Success!'); is like using SP.UI.DialogResult.OK
Also, to manipulate the dialog window you'll need to have <script src="/_layouts/SP.UI.Dialog.js" type="text/javascript"></script> loaded somewhere.
See related post: commonModalDialogClose(SP.UI.DialogResult.OK, someValue) throws error

Cordova Android SMS plugin does not fire success or error callbacks

I am using the following plugin for Cordova with Android:
https://github.com/aharris88/phonegap-sms-plugin
I can validate that the SMS application opens and that a message is sent but the JS success or error callbacks are never fired.
The code is implemented as per the plugin so I cannot think why this is not working to trigger the callbacks. I am using it with Cordova 2.9 although re-written for 3.0 the plugin is compatible with a few modifications as follows.
In the sms JAVA file I had to update the dependencies like so:
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
In the JS file i removed the following line:
module.exports = sms;
And just hook onto the sms global variable for now which is working.
My JS to call the SMS function follows the same as in the example provided:
var number = '123456789';
var message = 'foo!';
var intent = "INTENT"; //leave empty for sending sms using default intent
var success = function() {
$.magnificPopup.close();
};
var error = function(e) {
alert('Message Failed:' + e);
};
sms.send(number, message, intent, success, error);
UPDATE
If I remove the INTENT then the SMS is fired with the default SMS application automatically and things work as expected.
However, is there a way to trigger a JS call back when the message is sent from the SMS application?
The updated version should resolve your issue.
https://github.com/aharris88/phonegap-sms-plugin

Categories