我在测试机上测试一切正常,通过测试证书也能正确的把推送的消息发到测试手机上。但是上线后却发现了一个尴尬的问题,就是推送的数据库里没有任何数据。软件安装的时候也没有提示有推送服务,询问是否打开这一项。在手机的“设置-->通知”里面查找。无论是“在通知中心”和“不在通知中心”都没有找到我的应用。
请教一下大家,这是怎么会事?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound ];
return YES;
}
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *token = [NSString stringWithFormat:@"%@",deviceToken];
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
int alertStatus = 0;
int badgeStatus = 0;
if (types & UIRemoteNotificationTypeAlert) {
alertStatus = 1;
}
if (types & UIRemoteNotificationTypeBadge) {
badgeStatus = 1;
}
if (types == UIRemoteNotificationTypeNone)
{
NSLog(@"我已经关闭了推送通知");
}else {
//写入数据库
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString: pushUrl]];
[request addPostValue:token forKey:@"device_token"];
[request addPostValue:[NSNumber numberWithInt:alertStatus] forKey:@"alert"];
[request addPostValue:[NSNumber numberWithInt:badgeStatus] forKey:@"badge"];
[request startAsynchronous];
}
token = nil;
}
请教一下大家,这是怎么会事?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound ];
return YES;
}
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *token = [NSString stringWithFormat:@"%@",deviceToken];
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
int alertStatus = 0;
int badgeStatus = 0;
if (types & UIRemoteNotificationTypeAlert) {
alertStatus = 1;
}
if (types & UIRemoteNotificationTypeBadge) {
badgeStatus = 1;
}
if (types == UIRemoteNotificationTypeNone)
{
NSLog(@"我已经关闭了推送通知");
}else {
//写入数据库
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString: pushUrl]];
[request addPostValue:token forKey:@"device_token"];
[request addPostValue:[NSNumber numberWithInt:alertStatus] forKey:@"alert"];
[request addPostValue:[NSNumber numberWithInt:badgeStatus] forKey:@"badge"];
[request startAsynchronous];
}
token = nil;
}