我正在尝试很多事情,但在杀死app nate nate nate nate nate nate nate nate nate
时尚未成功获得无声通知在这里代码我正在尝试..
APS数据:
{
"aps": {
"content-available": 1,
"sound": ""
}
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSDictionary *userInfo1 = userInfo;
NSLog(@"userInfo: %@", userInfo1);
//self.textView.text = [userInfo description];
// We can determine whether an application is launched as a result of the user tapping the action
// button or whether the notification was delivered to the already-running application by examining
// the application state.
if (application.applicationState == UIApplicationStateActive)
{
//opened from a push notification when the app was on background
NSLog(@"userInfoUIApplicationStateactive->%@",[userInfo objectForKey:@"aps"]);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification" message:[NSString stringWithFormat:@"Your App name received this notification while it was Running:n%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else
{
// a push notification when the app is running. So that you can display an alert and push in any view
NSLog(@"userInfoUIApplicationStateBackground->%@",[userInfo objectForKey:@"aps"]);
[self scheduleAlarmForDate1:[NSDate date]alarmDict:userInfo];
}
}
有效载荷的aps
字典中不得包含警报,声音或徽章键。
{
"aps":{
"content-available" : 1
}
}
请尝试。
您应该像AppDelegate.m
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
NSDictionary *aps = [userInfo objectForKey:@"aps"];
NSLog(@"hello");
NSLog(@"userinfo---->>>>%@",userInfo);
[UIApplication sharedApplication].applicationIconBadgeNumber=[[aps objectForKey:@"badge"] integerValue];
[self application:application didReceiveRemoteNotification:userInfo];
}