NSError *parseError = nil;
id<SINPhoneNumber> phoneNumber = [SINPhoneNumberUtil() parse:telephone
defaultRegion:#"MX"
error:&parseError];
NSString *phoneNumberInE164 = [SINPhoneNumberUtil() formatNumber:phoneNumber
format:SINPhoneNumberFormatE164];
id<SINVerification> verification = [SINVerification SMSVerificationWithApplicationKey:SINCH_API_KEY
phoneNumber:phoneNumberInE164];
[verification initiateWithCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(#"sucess");
} else {
NSLog(#"error : %#", error.description);
}
}];
This is the error message:
Error Domain=SINVerificationErrorDomain Code=6 "No route to destination." UserInfo={SINErrorReference=A:SINCH_API_KEY_3xgIxZ48c0yRxvHzfCo0ng, SINHTTPStatusCode=422, NSLocalizedDescription=No route to destination., NSUnderlyingError=0x1360c7020 {Error Domain=SINVerificationServiceErrorDomain Code=42201 "No route to destination." UserInfo={SINErrorReference=A:SINCH_API_KEY_3xgIxZ48c0yRxvHzfCo0ng, NSLocalizedDescription=No route to destination., SINHTTPStatusCode=422}}}
I am sure that my phone number and app key is correct. I have set dashboard->verification>public. Any idea?
The Sinch Verification API seems to be offline. I have tested with the JavaScript SDK and the REST API. Each result is the same when attempting to create a verification.
The HTTP status code is 422. This typically means the server cannot execute the instructions sent in the JSON. A likely cause would be a breaking change to the server code was done without updating the SDKs or API documentation.
I have sent a message to them with a link to this ticket.
It was a temporary service disruption
From the documentation:
//client side
SINVerificationErrorInvalidInput = 1,
SINVerificationErrorIncorrectCode = 2, //code doesn't match
SINVerificationErrorCalloutFailure = 3,
SINVerificationErrorTimeout = 4,
SINVerificationErrorCancelled = 5,
// Sinch backend service error
SINVerificationErrorServiceError = 6
SINVerificationErrorServiceError should be reported to and handled by Sinch team
Related
I have a tiny Square iOS POS testing app to get the setup working properly but alas, no such luck - it charges $1.00 and the card is correctly processed, but the callback does not happen. The Square app just drops control and gives the screen back to my calling view controller - it does not return to the appDelegate. I have sent this project to Square, hoping for help, but they refuse, saying it is an implementation problem. However it definitely is a problem with Square's documentation, not implementation, as I have set up everything perfectly including the info file, the URL, the appID etc as defined. I am looking for help.
API call follows:
//------ API to Square right here ******-----------------
let callbackURL = URL(string: "POSSDKTest2://")!
var money: SCCMoney?
do {
// Specify the amount of money to charge.
let todaysFeePennies = Int(TodaysFee) * 100
money = try SCCMoney(amountCents: todaysFeePennies, currencyCode: "CAD")
} catch {
print("money conversion failed.")
}
//SCCAPIRequest.setApplicationID(masterInfo.SquareAppID)
SCCAPIRequest.setApplicationID("sq0idp-TbgQGqSrC84qkfcXSTntNg")
var request: SCCAPIRequest?
do
{
let LoginID = "TestPatient"
squareTransDone = false
print("FVC Initiating payment api request")
print("callback: \(callbackURL)")
print("money: \(money!)")
print("LoginID: TestPatient")
print("FVC Initiating payment api request")
request =
try SCCAPIRequest(
callbackURL: callbackURL,
amount: money!,
userInfoString: LoginID,
locationID: "",
notes: "Testing SDK",
customerID: nil, // used by Square, not us
supportedTenderTypes: .all,
clearsDefaultFees: false,
returnsAutomaticallyAfterPayment: false,
//.true makes no difference!
disablesKeyedInCardEntry: false,
skipsReceipt: false)
} catch {
print("SCCAPIRequest croaked.")
}
// Open Point of Sale to complete the payment.
var success = false
do {
try SCCAPIConnection.perform(request!)
success = true
print("api success!")//this actually shows in the log
} catch let error as NSError {
print("Error detected: \(error.localizedDescription)")
}//end API
}//------------------------------------
The calling view controller has a screen with a button saying "Post $1.00 payment" which comes to this code. The log shows "api success" and no error message.
Image of app's info.plist attached showing setup for Square.
info.plist screenshot
Image of Credentials from Square Developer page attached.
Credentials page
I am using Sinch framework for Mobile verification. For some numbers Sinch returns me an error that says "Operator not supported".
I am unable to understand why this error is returned. Could some one point me to the documentation where this is explained.
If of any help I'm number concerned is an Indian number.
Thank in advance.
Updated - December 04, 2015
Heres the code that returns me the error
#import <SinchVerification/SinchVerification.h>
#interface EnterPhoneNumberViewController () {
id<SINVerification> _verification;
}
#end
#implementation EnterPhoneNumberViewController
- (void)viewDidLoad {
_verification = [SINVerification SMSVerificationWithApplicationKey:#"blah-blah-blah-blah" phoneNumber:phoneNumberTextField.text];
//set up a initiate the process
[_verification initiateWithCompletionHandler:^(BOOL success, NSError *error) {
if(!success) {
//code returned with failure
NSLog(#"Error while verification : %ld %#",(long)[error code],[error localizedDescription]);
[errorLabel setText:[error localizedDescription]];
}
else {
//code returned with Success
NSLog(#"SMS With Code Successfully Sent");
}
}];
}
today we released a new sdk to help you neter number, check out downloads sinch.com/download this shoule help you getting correct numbers sent for verification. The error means that that number/carrier is not supported. This can be for a number of reasons, google voice number, blocked because of fraud an unsupported carrier.
If you think that that is an error on that particular number please contact support#sinch.com with that number and we can look in to it.
I am new in windows phone.Iam developing one app.in this app I want to send pushnotifications.how to send and receive pushnotifications in windows phone 8 using c#.please help me.
public string SendNotificationToWindows(string message, string notificationId)
{
try
{
//string subscriptionUri = "http://db3.notify.live.net/throttledthirdparty/01.00/AwYAAACKB3Noan4l%2bojXM5%2f3TDodPTegXbZxtTAzRktj3eWFOYmjjN1FPIdkuduXrwYZByFKLxy1gXy8rCmf1FSM6GH92rva7ecbQ%2b1%2bnGYxLWxoAI0GL03fZbV29p%2fu%2fJYrHQI%3d";
string subscriptionUri = "http://db3.notify.live.net/throttledthirdparty/01.00/aHR0cHM6Ly9zaW4ubm90aWZ5LndpbmRvd3MuY29tLz90b2tlbj1Bd1lBQUFEQjE1TzJMQWMlMmZBQldlUlpQendHMlglMmJRNWlPbzVUOVF3UUtXeUFQJTJic2clMmZFREhuSHM0bDBVN2tFN2prSXVJYU1hWEZIdmJYR2t6cEpQJTJiaCUyYldJSVJFTjBSd244TzJRNFV5RUs0OFJKZDdLSWJPeXVUMXFNWVNwa0Y3bmlBak5kZmslM2Q=";
//string subscriptionUri = "https://hk2.notify.windows.com/?token=AwYAAACKB3Noan4l%2bojXM5%2f3TDodPTegXbZxtTAzRktj3eWFOYmjjN1FPIdkuduXrwYZByFKLxy1gXy8rCmf1FSM6GH92rva7ecbQ%2b1%2bnGYxLWxoAI0GL03fZbV29p%2fu%2fJYrHQI%3d";
//string subscriptionUri = "http://sn1.notify.live.net/throttledthirdparty/01.00/aHR0cHM6Ly9zaW4ubm90aWZ5LndpbmRvd3MuY29tLz90b2tlbj1Bd1lBQUFEckVzRmdhR2phMXQ1aVo5MGdvRzAzejR5cE1SJTJiMHIwR2ZQc0Q0U0xzYnJOY2V3JTJmdU5pek1kZER4ZG9UdE5CM05PbjQ4dU9yUktzakN0U2JJa2lObmdBQVljQzdScDZ0blRBZlBDWjB4OWlZMDJRSDF3JTJieHM1ZzVMSTlWSXdGZWslM2Q=";
// string subscriptionUri = "https://sin.notify.windows.com/?token=AwYAAADrEsFgaGja1t5iZ90goG03z4ypMR%2b0r0GfPsD4SLsbrNcew%2fuNizMddDxdoTtNB3NOn48uOrRKsjCtSbIkiNngAAYcC7Rp6tnTAfPCZ0x9iY02QH1w%2bxs5g5LI9VIwFek%3d";
var sendNotificationRequest = (HttpWebRequest)WebRequest.Create(subscriptionUri);
// Create an HTTPWebRequest that posts the toast notification to the Microsoft Push Notification Service.
// HTTP POST is the only method allowed to send the notification.
sendNotificationRequest.Method = "POST";
// The optional custom header X-MessageID uniquely identifies a notification message.
// If it is present, the same value is returned in the notification response. It must be a string that contains a UUID.
// sendNotificationRequest.Headers.Add("X-MessageID", "<UUID>");
// Create the toast message.
var toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + message + "</wp:Text1>" +
"</wp:Toast> " +
"</wp:Notification>";
// Set the notification payload to send.
byte[] notificationMessage = Encoding.Default.GetBytes(toastMessage);
// Set the web request content length.
sendNotificationRequest.ContentLength = notificationMessage.Length;
sendNotificationRequest.ContentType = "text/xml";
sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast");
sendNotificationRequest.Headers.Add("X-NotificationClass", "2");
using (var requestStream = sendNotificationRequest.GetRequestStream())
{
requestStream.Write(notificationMessage, 0, notificationMessage.Length);
}
// Send the notification and get the response.
var response = (HttpWebResponse)sendNotificationRequest.GetResponse();
var notificationStatus = response.Headers["X-NotificationStatus"];
var notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
var deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];
// Display the response from the Microsoft Push Notification Service.
// Normally, error handling code would be here. In the real world, because data connections are not always available,
// notifications may need to be throttled back if the device cannot be reached.
var rep = notificationStatus + " | " + deviceConnectionStatus + " | " + notificationChannelStatus;
return rep;
}
catch (Exception ex)
{
return ex.ToString();
// TextBoxResponse.Text = "Exception caught sending update: " + ex.ToString();
}
this is my service I am sending on uri to this service,but I don't know whenever came to response it will throw exeception"The remote server returned an error: (400) Bad Request."but i dont know what type of uri will give.in this uri with send one key but which type of key will send please anyone reply me
You could check out PushSharp It appears to have been updated for the new notification payload formats in Windows Phone 8. Here is the server code for sending Push Notifications from a Server and in this link you can find the implementation for the Windows Phone.
Basically, there are two types of Push notification your app may be using in Windows Phone 8.1.
MPNS: Microsoft Push Notification Service
WNS: Windows Notification Service.
MPNS is the old style notification service used in Windows Phone 7 and 8. WNS is the Windows 8 style notification which is available to Applications specifically targeting Windows Phone 8.1. (Windows Phone Silverlight 8.1 apps and Windows Phone 8.1 (Windows runtime) apps.
PushSharp appears to support both types of notification services, MPNS in the PushSharp.WindowsPhone libraries and WNS in the PushSharp.Windows libraries.
Also it might be worth checking out Azure for the same.
Here is a tutorial for the same => Send push notifications to authenticated users
Below are the steps needed for push notification for windows phone .
Your app requests a push notification URI from the Push client service.
The Push client service negotiates with the Microsoft Push Notification Service (MPNS), and MPNS returns a notification URI to the Push client service.
The Push client service returns the notification URI to your app.
Your app can then send the notification URI to your cloud service.
When your cloud service has info to send to your app, it uses the notification URI to send a push notification to MPNS.
MPNS routes the push notification to your app.
See this MSDN page to understand push notification in detail.
I tried to send notification manually with the following code:
void SendToastMessage(string pushUri, string message)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(pushUri);
request.ContentType = "text/xml";
request.Method = "POST";
request.Headers.Add("X-MessageID", Guid.NewGuid().ToString());
request.Headers.Add("X-NotificationClass", "2");
request.Headers.Add("X-WindowsPhone-Target", "toast");
string toastMessage = #"<?xml version=""1.0"" encoding=""utf-8""?>
<wp:Notification
xmlns:wp=""WPNotification"">
<wp:Toast>
<wp:Text1>{0}</wp:Text1>
<wp:Text2>{1}</wp:Text2>
</wp:Toast>
</wp:Notification>";
string toastXml = string.Format(toastMessage,
"sample:",
message);
byte[] notificationMessage = Encoding.UTF8.GetBytes(toastXml);
request.ContentLength = notificationMessage.Length;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(notificationMessage,
0,
notificationMessage.Length);
}
try
{
HttpWebResponse response =
(HttpWebResponse)request.GetResponse();
return;
}
catch (Exception ex)
{
return;
}
}
This code worked perfectly fine to me a year earlier and it still does. But make sure your pushUri is correct.
My app on the appstore is accessing the iPhone contacts, after the users downloaded it on iOS 6 it can't access the iPhone contacts while its working fine on iOS 5
the problem is the new privacy settings apple has put in iOS 6 .. so after searching i found out that i have to do the following in my code to be able to access the user contacts:
//in order to test addressbook availability we have to attempt to create an addressbook instance using ABAddressBookCreateWithOptions
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef,
^(bool granted, CFErrorRef error) {
if (granted)
[self loadContacts];
});
} else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
[self loadContact];
} else {
}
#endif //end iOS6+
//ABAddressBookCreateWithOptions not available or succeeded. return YES;
[self loadContacts];
My problem now is while debugging on the device, the alert is not showing, i don't know why ?
I know that the above code should work fine, but only when the app is submitted to the appstore but i want to test that in debug mode before submission ?
Any advice ?
Appreciate your support.
Thanks.
I have managed to get it resolved
Here is the new code after a slight modification:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
__block MyClassType *controller = self;
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef,
^(bool granted, CFErrorRef error) {
if (granted)
[controller loadContacts];
});
} else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
[self loadContacts];
} else {
}
#else
[self loadContacts];
#endif
The key to be able to test it is to Reset the Privacy and location settings from Settings>>General>>Reset>>Reset Location & Privacy
It worked fine with me.
Resetting Location & Privacy doesn't work for me.
My authorization status is always kABAuthorizationStatusAuthorized, regardless of whether I clear simulator settings and then reset Location and Privacy.
Has anyone had success using Beeblex to validate in-app purchases? I have an app that is already live in the app-store with in-app purchases enabled and working. In light of the recent hacking news concerning in-app purchases I am attempting to update it to use Beeblex to validate purchases. The problem is that Beeblex always returns a result saying that Apple claims the purchase to be invalid. I am hoping someone on here is successfully using Beeblex and can post a working example. I am following their advice to let the purchase go completely through, then validate it. I basically just cut and pasted their code right off their website, so not sure what I could do differently.
- (void) validatePurchaseOrRestore
{
//The transaction has been reported as complete for a new purchase of the upgrade. I now make use of Beeblex
//to verify the receipt to ensure the purchase is legit.
if (![BBXIAPTransaction canValidateTransactions])
{
transactionResult = 4;
return; // There is no connectivity to reach the server.
// You should try the validation at a later date.
}
BBXIAPTransaction *bbxTransaction = [[BBXIAPTransaction alloc] initWithTransaction:transactionCopy];
bbxTransaction.useSandbox;
[bbxTransaction validateWithCompletionBlock:^(NSError *error)
{
if (bbxTransaction.transactionVerified)
{
if (bbxTransaction.transactionIsDuplicate)
{
// The transaction is valid, but duplicate - it has already been
// sent to Beeblex in the past.
transactionResult = 1;
}
else
{
// The transaction has been successfully validated
// and is unique.
NSLog(#"Transaction data: %#", bbxTransaction.validatedTransactionData);
transactionResult = 0;
}
}
else
{
// Check whether this is a validation error, or if something
// went wrong with Beeblex.
if (bbxTransaction.hasServerError)
{
// The error was not caused by a problem with the data, but is
// most likely due to some transient networking issues.
transactionResult = 4;
}
else
{
// The transaction supplied to the validation service was not valid according to Apple.
transactionResult = 3;
purchaseDidFail = TRUE;
}
}
}];
}