How can I determine if a user cancels a CredentialsPicker? - windows-8

How can I determine if a user cancels a CredentialsPicker?

You can try this in the Credential Picker sample. Using scenario 1, for example, you'll see that cancelation of the picker will return a CredentialPickerResults object (in the promise results or from the API in C#), in which the ErrorCode property (errorCode in JS) will contain x800704c7 which is the Win32 error code ERROR_CANCELLED.
If for some reason the credential picker cannot be displayed, that would generate an error from the credential picker itself (and be picked up by an error handler give to a promise.then). The case you're describing is that the credential picker succeeded, but the user canceled.

Related

How to fix error "NOT_LOGGED_IN" in Voximplant?

I'm trying to call with Voximplant and get this error. What's wrong?
CallManager: _handleAppStateChange: Current app state changed to inactive
CallManager.js:151 CallManager: _handleAppStateChange: Current app state changed to background
Client.js:563 Client: emit: no handlers for event: ConnectionClosed
CallManager.js:151 CallManager: _handleAppStateChange: Current app state changed to active
how can I make connection again in this situation ?
because of this user are not vaild to call another user. I have to close app and open again to make connection again
backend.js:12688 Possible Unhandled Promise Rejection (id: 0):
"NOT_LOGGED_IN"
You can check the client state before you call Client.call method. If the client state is not logged in, you need to connect and log in again, you can use login with access token to log in "silently", i.e. do not ask user to enter the password

UI Error while calling app script functions through app script API

I have written functions in the app script bound to a google sheet that validates sheet data and shows a pop up in the sheet when there is an error.
Now, I am calling same functions form API calls in a Node js application to return a validation response without interacting google sheet.
API calls are successful, function gets called but unable to initialize UI.
I just don't want to write duplicate functions for same purpose but without accessing UI.
I get an error that says Script error message: Exception: Cannot call SpreadsheetApp.getUi() from this context.
How do I solve this issue by retaining the UI calling functionality of the app script functions and also getting work done through API?
You can put the call in a try catch block.
try {
SpreadsheetApp.getUi();
} catch (f) {
// do nothing here
}

How can I react to a message with a pub/sub bot

I have created a Card with a button and a onClick action that successfully sends a message to my client with type "CARD_CLICKED".
When I try to respond to this message with either a type "NEW_MESSAGE" or "UPDATE_MESSAGE" message, this is displayed as a new message, while the API tries for three times to send that CARD_CLICKED event to my bot until it gives up with the visual error: "Unable to contact [bot]. Try again later."
I guess this is similar to
Interactive button doesn't work properly when using pub/sub
Interactive cards hangout chat Api
but I am using a golang client and the answer to these questions didn't help me...
My code to respond to the "CARD_CLICKED" message:
func handleClick(message *chat.DeprecatedEvent) *chat.Message {
log.Debugf("User %s instructed me to execute %s", message.User.DisplayName, message.Action.ActionMethodName)
response := &chat.Message{
ActionResponse: &chat.ActionResponse{Type: "UPDATE_MESSAGE"},
Thread: &chat.Thread{Name: message.Message.Thread.Name},
Space: &chat.Space{Name: message.Message.Space.Name, Type: message.Message.Space.Type},
Text: "CARD CLICKED!",
}
return response
}
My code is based on this project: https://github.com/jforman/hangbot
Found out what the main issue was... I was calling the .Create() function - which created a new message and thus - even though the Action Response was set correctly - this was not interpreted as a response to the click event:
https://github.com/jforman/hangbot/blob/master/hangbot.go#L79
After I switched to calling .Update() - Chat would not display the "Unable to contact" message about my bot any more.
What remains is that the click event is still sent to me three times, but I'm filtering events now based on the eventTime, which works ok for now.

Detecting user canceling SKReceiptRefreshRequest to sign in

When we need to refresh an iOS7 receipt, the appropriate way to do that is to use SKReceiptRefreshRequest. This brings up an Apple dialog for the user to sign in using their Apple ID. It also allows them to Cancel. How can we detect if the user presses Cancel? (Of course, in iOS6, this can be done using catching the cancel event for [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]).
The SKReceiptRefreshRequest object has a delegate with two methods:
- (void)requestDidFinish:(SKRequest *)request;
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error;
In my code the requestDidFinish delegate method is called if the user does or does not press cancel.
The reason this is important to me is that I want to cancel the restore process if the user presses Cancel. If there was simply no receipt present after the refresh request, this might be relatively easy. However, sometimes there is a receipt (with some purchases) present in the app before the SKReceiptRefreshRequest, and so it stays in the app if the user cancels from the sign-in dialog.
I have two ideas for how to do this:
1) Delete the receipt from the bundle prior to the refresh request. The apparent problem with this is that the app can't remove files from the bundle (e.g., see Delete file from bundle after install). I tried. Nope.
2) Check the bytes of the receipt before the refresh request and after; if they differ, then this should indicate the user didn't press Cancel. If they don't differ, I'm not sure that does indicate they pressed Cancel. If the receipt contains purchases, I think that the bytes will differ because a refreshed receipt should have different transaction id's (but the same "original" transaction id's). If the receipt contains no purchases, I'm not sure about that.
Update, 11/9/15; I've just noticed that the delegate response to the user pressing Cancel appears to have changed. Now, didFailWithError is called. The problem of detecting user cancellation remains, however. How can we distinguish between the user pressing Cancel and a genuine error? I've been testing on iOS8.4 and iOS9.2 (beta). I have now reported this lack of distinguishability as a bug to Apple (bug #23476210).
Update, 11/10/15; This issue does not appear with iOS 9.0.2! I just tried this now with all three systems, with the same app binary, in the same approximate interval of time (within 20 minutes for all three systems): (A) iOS9.2 (13C5050d): Issue does occur (didFailWithError is called and can't distinguish between a real error and user pressing cancel), (B) iOS9.0.2, issue does not occur (requestDidFinish is called), and (C) iOS8.4.1, issue does occur. With all three system versions, this is running on real hardware, not the simulator.
iOS 9.2.1, Xcode 7.2.1, ARC enabled
I understand you asked this 2 years ago, but I recently had my run in with this issue and found a solution, and wanted to share here so others can save some time.
1) You may elect to store the receipt into keychain and access a copy of it, this allows you to delete it or refresh it as you see fit.
2) Yeah you can definitely check if it changed, I think the simplest way to do that is to use:
[receipt isEqualToData:(NSData *)(copyReceiptObject)]
My suggestion is as follows:
The key is to expect the error you get from the method:
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error;
that gets called when the user taps cancel after the log in dialogue comes up to sign in to iTunes Store. There are many custom was you could do the refresh request, so the results may vary, but here is the different error you get for my request:
When there is no connection to iTunes:
Error Domain=SSErrorDomain Code=110 "Cannot connect to iTunes Store"
UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store,
NSUnderlyingError=0x13c76d680 {Error Domain=NSURLErrorDomain
Code=-1009 "Cannot connect to iTunes Store"
UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store,
NSErrorFailingURLStringKey=
{ your product ids and corresponding URIs here }
, _kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12,
NSLocalizedDescription=The Internet connection appears to be offline.}}}
When the user taps cancel:
Error Domain=SSErrorDomain Code=16 "Cannot connect to iTunes Store"
UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store,
NSUnderlyingError=0x13c6ac7b0 {Error Domain=AKAuthenticationError
Code=-7003 "(null)"}}
The easiest I think is to check the error.code, if you want to get more complicated you may choose to parse the full error string to get more details about the error.
In my case, no connection error code is 110 and when the user cancels the log in the error code is 16. Handle the error.

navigationservice.navigate not available on the vs2013 project

I have two page application and the main page is default is "MainPage.xaml" and the second one is "AddPerson.xaml" when user click a button on main page I want the app to take user to "AddPerson" page.
And I wrote following for the Click event of the button
Me.Frame.Navigate(System.Type.GetType("AddPerson.xaml"))
and I am getting the following error
An exception of type 'System.NullReferenceException' occurred in MedicineSchedule.exe but was not handled in user code
Additional information: Object reference not set to an instance of an object.
If there is a handler for this exception, the program may be safely continued.
I tried other method of navigationservice.navigate which I cannot find the class in VS2013 express at all. The only method available is Me.Frame.Navigate in my project, please let me know how I can get this simple thing to work.
If it was .net 2.0 I would simple called new form with form.lod or something similar.
This doesn't work?
this.Frame.Navigate(typeof(AddPerson));
If you want/have to use a string take a look at the reply here:
convert string to type of page