if ([[NSUserDefaults standardUserDefaults] boolForKey:XXXXX]) {
if ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone Simulator"]) {
UIButton *devPushNoteButton = [[UIButton alloc] initWithFrame:CGRectZero];
[devPushNoteButton setBackgroundColor:[UIColor blackColor]];
[devPushNoteButton setTitle:@"*for dev demo push*" forState:UIControlStateNormal];
[devPushNoteButton.titleLabel setFont:[UIFont systemFontOfSize:13.0f]];
[devPushNoteButton sizeToFit];
[devPushNoteButton addTarget:self action:@selector(onCustomRightDemoPushButtonClick:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *devPushNoteBarButton = [[UIBarButtonItem alloc] initWithCustomView:devPushNoteButton];
[self.navigationItem setRightBarButtonItem:devPushNoteBarButton];
}
}
----------------实现方法
- (void)onCustomRightDemoPushButtonClick:(id)sender {
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate didReceiveRemoteNotification:@{@"aps": @{@"alert": @"fahsfagsdgEWGQEGQRGHQRGWRJJKWRBJBNW,NRJBNWJRNBKNRWKNBNJfn 23456789 jbjsnBNJsbnlj http://google.com",
@"badge": @"0"},
@"type": @"D",
@"goTo": @"H",
@"sendTime": /*@((int)[[NSDate date] timeIntervalSince1970])*/ @1447228982669}
displayBanner:YES];
}