I have an urban airship account and my iOS app ist already configured with the system. My device token is on the server and if I send a test notification from the server I get the notification on my iphone. BUT how can I send a message FROM my iphone to another user? I haven't found any stuff about sending through iphone. This is my code:
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://go.urbanairship.com/api/push/"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSDictionary *push;
push = @{@"aps":@{@"alert":@"How are you?"},@"device_tokens":@[@"87892382J393FS77789S90909N82022312332"]};
and then I have to send it as json or something else???
OK this is my actually Method:
If I comment the line 6-10 out then I get for the NSLog:
I really don't know why it doesn't works!!!
This is an Example using the API V3
}
And The Response:
}
Just FYI, doing this would present a risk in a publicly released app.
Any push through UA requires your master secret to authenticate. If you added your master secret to the app, it would be viewable to a savvy hacker, who could then use it to send unauthorized pushes on your behalf. It has happened to people before.
It's not generally recommended.
As documentation on http://docs.urbanairship.com/reference/api/v3/intro.html says, requests are http ones with JSON body.
You need to authorize first. From documentation:
You can find in this question how to authorize on iOS:
And then I guess you should do like this:
Note that you need JSONKit to serialize your dictionary into string