File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -738,7 +738,7 @@ + (void)postNotification:(NSDictionary*)jsonData onSuccess:(OSResultSuccessBlock
738738 NSMutableURLRequest * request = [httpClient requestWithMethod: @" POST" path: @" notifications" ];
739739
740740 NSMutableDictionary * dataDic = [[NSMutableDictionary alloc ] initWithDictionary: jsonData];
741- dataDic[@" app_id" ] = app_id;
741+ dataDic[@" app_id" ] = dataDic[ @" app_id " ] ?: app_id;
742742
743743 NSData * postData = [NSJSONSerialization dataWithJSONObject: dataDic options: 0 error: nil ];
744744 [request setHTTPBody: postData];
Original file line number Diff line number Diff line change @@ -1936,6 +1936,27 @@ - (void)testSendTagsBeforeRegisterComplete {
19361936 XCTAssertEqualObjects (lastHTTPRequset[@" identifier" ], @" 0000000000000000000000000000000000000000000000000000000000000000" );
19371937}
19381938
1939+
1940+ - (void )testPostNotification {
1941+ [self initOneSignal ];
1942+ [self runBackgroundThreads ];
1943+ XCTAssertEqual (networkRequestCount, 1 );
1944+
1945+
1946+ // Normal post should auto add add_id.
1947+ [OneSignal postNotification: @{@" contents" : @{@" en" : @" message body" }}];
1948+ XCTAssertEqual (networkRequestCount, 2 );
1949+ XCTAssertEqualObjects (lastHTTPRequset[@" contents" ][@" en" ], @" message body" );
1950+ XCTAssertEqualObjects (lastHTTPRequset[@" app_id" ], @" b2f7f966-d8cc-11e4-bed1-df8f05be55ba" );
1951+
1952+ // Should allow overriding the app_id
1953+ [OneSignal postNotification: @{@" contents" : @{@" en" : @" message body" }, @" app_id" : @" override_app_UUID" }];
1954+ XCTAssertEqual (networkRequestCount, 3 );
1955+ XCTAssertEqualObjects (lastHTTPRequset[@" contents" ][@" en" ], @" message body" );
1956+ XCTAssertEqualObjects (lastHTTPRequset[@" app_id" ], @" override_app_UUID" );
1957+ }
1958+
1959+
19391960- (void )testFirstInitWithNotificationsAlreadyDeclined {
19401961 [self backgroundModesDisabledInXcode ];
19411962 notifTypesOverride = 0 ;
You can’t perform that action at this time.
0 commit comments