2

i have one php file for push notification service and working.. i want use that php file in xcode, for example send device token and message like an query string..

i used this code

NSString *urlString = @"http://xxxxxx.com/send-notification.php?token=%@&message=test";                       
NSString *escapedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *add = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",escapedString,token]];`

but not working i don't know how to call this php..

thanks for all helps

1 Answer 1

1

You will need to create your url in a different way. In your code, the %@ in the initial urlString will not be replaced later on.

Instead, try writing your code like this:

NSString *urlString = [NSString stringWithFormat:@"http://xxxxxx.com/send-notification.php?token=%@&message=test", token];
NSString *escapedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *add = [NSURL URLWithString:escapedString];

After you've created the NSUrl instance, you will have to open a http connection to the url.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.