• Tomo Okada
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
API "/ connect / notifications / push" will always result in an error.
We completed "Step 4. Using Apex Triggers to Send Push Notifications" on "Salesforce Mobile Push Notifications Implementation Guide."
Also, "Send test notification" has been succeeded.
Both the sender and the recipient are the same ORG accounts.
I am a development in the "SalesforceMobileSDK for iOS".
While using Chatter REST API for exchanging the data, we're attempting for Push notification using Push Notification resources.
However we can't send any Push Notification but recieve UNKNOWN_EXCEPTION even though we set upthe  POST Palameter referring to API Guide. 

Code you are using is following.
 
NSMutableArray *sendUserIds = [[NSMutableArray alloc] init];
[sendUserIds addObject:@"UserID1"];
[sendUserIds addObject:@"UserID2"];
[sendUserIds addObject:@"UserID3"];
    
NSString *payload = @"{'aps':{'alert':'test', 'badge':0, 'sound':'default'}}";
NSDictionary *sendDic = [[NSDictionary alloc] initWithObjectsAndKeys:@"PushTest", @"appName", @"PushTest", @"namespace", sendUserIds, @"userIds", payload, @"payload", nil];

// URL and Request Object creation
NSString *url = [NSString stringWithFormat:@"/%@/connect/notifications/push",@"v32.0"];
SFRestRequest *req =[SFRestRequest requestWithMethod:SFRestMethodPOST path:url queryParams:sendDic];
    
//POST Execution
[[SFRestAPI sharedInstance] sendRESTRequest:req failBlock:^(NSError *e) {
    NSLog(@"/connect/notifications/push error:: %@",e);
} completeBlock:^(id jsonResponse) {
    NSLog(@"MessegeOk");
}];

Error trace after the above code execution will be below.
 
--------
Response
--------
[{"message":"An unexpected error occurred. Please include this ErrorId if you contact support: 633409168-7007 (1770975217)","errorCode":"UNKNOWN_EXCEPTION"}]
, [The operation couldn’t be completed. (NSURLErrorDomain error 500.)]
2015-02-17 10:06:51:927 [592:807] ERROR|SFNetworkOperation|callDelegateDidFailWithError An unexpected error occurred. Please include this ErrorId if you contact support: 633409168-7007 (1770975217)
2015-02-17 10:06:51.927 [592:148638] -[MKNetworkOperation operationFailedWithError:] [Line 1792] State: 0
2015-02-17 10:06:51.932 [592:148875] /connect/notifications/push error:: Error Domain=NSURLErrorDomain Code=500 "An unexpected error occurred. Please include this ErrorId if you contact support: 633409168-7007 (1770975217)" UserInfo=0x1d2a3d30 {NSLocalizedFailureReason=UNKNOWN_EXCEPTION, SFOriginalApiError=<CFArray 0x1d290f40 [0x39ef4460]>{type = immutable, count = 1, values = (
	0 : <CFBasicHash 0x1d298640 [0x39ef4460]>{type = immutable dict, count = 2,
entries =>
	0 : <CFString 0x1d2b95c0 [0x39ef4460]>{contents = "message"} = <CFString 0x1d29b8e0 [0x39ef4460]>{contents = "An unexpected error occurred. Please include this ErrorId if you contact support: 633409168-7007 (1770975217)"}
	2 : <CFString 0x1d2b0860 [0x39ef4460]>{contents = "errorCode"} = <CFString 0x1d2b63c0 [0x39ef4460]>{contents = "UNKNOWN_EXCEPTION"}
}

)}, NSLocalizedDescription=An unexpected error occurred. Please include this ErrorId if you contact support: 633409168-7007 (1770975217)}