I can get the device token for my iPad but the problem how to send it to the database in server via php code .
I had test the php code and it is working .
this my function to send the device token :
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSString *devToken = [[[[deviceToken description]
stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"%@",devToken);
NSString *sli = [NSString stringWithFormat:@"http://localhost:8888/insertiphone.php?number=%@",devToken];
NSURL *url = [NSURL URLWithString:sli];
NSData *test = [NSData dataWithContentsOfURL:url];
if ([test length] == 0) {
NSLog(@"no done");
}
}
it is not working ..
and this is the php code :
<?php
function inserttodatabase(){
$con = mysql_connect("localhost","root","root");
mysql_select_db("my_db", $con);
mysql_query("INSERT INTO iphoneid (idip)
VALUES ($_GET[number])");
echo "done";
}
inserttodatabase();
?>
updated , I tried also with these codes but not working
NSString *devToken = [[[[deviceToken description]
stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSString *sli = [NSString stringWithFormat:@"http://localhost:8888/insertiphone.php? number=%@",devToken];
NSLog(@"%@",sli);
NSURL *url = [NSURL URLWithString:sli];
NSURLRequest *urlr = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];
NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:urlr delegate:self];
if (connection){
NSLog(@"connecting");
}else {
NSLog(@"error");
}
it says connecting but nothing will be inserted into the database