iPhoneのホーム画面でアプリアイコンに数字のバッジを付けたかったのだが、どーしても付けることが出来なかった。
そもそも、delegeteとか、notificationが理解できてないのが悪いのだが、
それにしてもまる二日ほど悩んだ。
参考サイト
iOS8 ローカル通知の実装についてメモ。 | scherzi a parte
なんとなく、iPhone本体(もしくはシミュレータ)側で通知の許可ができてないのかも、、、と思ってたが、設定画面見ても分からず。
色々とさまよった挙句上記サイトに行き着いた。
AppDelegate.mで下記のように通知の許可を求めれば良いようだ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
@implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) { [[UIApplication sharedApplication] registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert| UIUserNotificationTypeBadge| UIUserNotificationTypeSound categories:nil]]; } return YES; } |