@@ -473,7 +473,7 @@ + (void)postNotification:(NSDictionary*)jsonData {
473473}
474474
475475+ (void )postNotification : (NSDictionary *)jsonData onSuccess : (OSResultSuccessBlock)successBlock onFailure : (OSFailureBlock)failureBlock {
476- NSMutableURLRequest * request = [httpClient requestWithMethod: @" POST " path: @" notifications" ];
476+ NSMutableURLRequest * request = [httpClient requestWithMethod: @" GET " path: @" notifications" ];
477477
478478 NSMutableDictionary * dataDic = [[NSMutableDictionary alloc ] initWithDictionary: jsonData];
479479 dataDic[@" app_id" ] = app_id;
@@ -506,11 +506,30 @@ + (void)postNotificationWithJsonString:(NSString*)jsonString onSuccess:(OSResult
506506 if (jsonError == nil && jsonData != nil )
507507 [self postNotification: jsonData onSuccess: successBlock onFailure: failureBlock];
508508 else {
509- onesignal_Log (ONE_S_LL_WARN,[NSString stringWithFormat: @" postNotification JSON Parse Error: %@ " , jsonError]);
510- onesignal_Log (ONE_S_LL_WARN,[NSString stringWithFormat: @" postNotification JSON Parse Error, JSON: %@ " , jsonString]);
509+ onesignal_Log (ONE_S_LL_WARN, [NSString stringWithFormat: @" postNotification JSON Parse Error: %@ " , jsonError]);
510+ onesignal_Log (ONE_S_LL_WARN, [NSString stringWithFormat: @" postNotification JSON Parse Error, JSON: %@ " , jsonString]);
511511 }
512512}
513513
514+ + (NSString *)parseNSErrorAsJsonString : (NSError *)error {
515+ NSString * jsonResponse;
516+
517+ if (error.userInfo && error.userInfo [@" returned" ]) {
518+ @try {
519+ NSData * jsonData = [NSJSONSerialization dataWithJSONObject: error.userInfo[@" returned" ] options: 0 error: nil ];
520+ jsonResponse = [[NSString alloc ] initWithData: jsonData encoding: NSUTF8StringEncoding];
521+ } @catch (NSException * e) {
522+ onesignal_Log (ONE_S_LL_ERROR, [NSString stringWithFormat: @" %@ " , e]);
523+ onesignal_Log (ONE_S_LL_ERROR, [NSString stringWithFormat: @" %@ " , [NSThread callStackSymbols ]]);
524+ jsonResponse = @" {\" error\" : \" Unkown error parsing error response.\" }" ;
525+ }
526+ }
527+ else
528+ jsonResponse = @" {\" error\" : \" HTTP no response error\" }" ;
529+
530+ return jsonResponse;
531+ }
532+
514533/* Option:0, 1 or 2 */
515534+ (void )setNotificationDisplayOptions : (NSNumber *)option {
516535
0 commit comments