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

FD_
  • 12,947
  • 4
  • 35
  • 62
Burak Ogutken
  • 690
  • 10
  • 21

1 Answers1

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.

Emiel vl
  • 186
  • 2
  • 7