私は、プッシュ通知のボタンを表示するためにthis tutorialに従った。
登録通知をdidFinishLaunchingWithOptions
に登録してボタンを登録します。
しかし、ほとんどの場合、ボタンなしで簡単な通知を表示する必要があります。さまざまな通知のボタンを表示/非表示にする方法は?対話型プッシュ通知 - 非表示/表示ボタン
0
A
答えて
2
私はこれがあなたに役立つことを願っています。
Parameter Description. userInfo --> dictionary value for user needs. title --> notitification Title. fireDate --> trigger notification date and time. Interactive -> pass flag to set Interactive or normal notification.
-(void)setLocalnotfication:(NSDictionary *)userInfo title:(NSString *)title date:(NSDate *)fireDate Interactive : (BOOL)flag {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.alertBody = title;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;
if(flag) notification.category = @"Category name";
if([userInfo isKindOfClass:[NSDictionary class]]) notification.userInfo = userInfo;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
私はそれを作成するには、このコードを使用しています。
、あなたがUIUserNotificationSettings
更新する必要がありますなしボタンでインタラクティブな通知の別の種類を追加するための
func setLocalnotfication(userInfo: [NSObject : AnyObject], title: String, date fireDate: NSDate, Interactive flag: Bool) {
var notification: UILocalNotification = UILocalNotification()
notification.fireDate = fireDate
notification.alertBody = title
notification.timeZone = NSTimeZone.defaultTimeZone()
notification.soundName = UILocalNotificationDefaultSoundName
if flag {
notification.category = NCI
}
if (userInfo is NSDictionary.self) {
notification.userInfo = userInfo
}
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
3
より迅速。
いずれかのボタンのない新しい通知カテゴリUIMutableUserNotificationCategory
作成:既存のUIUserNotificationSettings
にこの新しいカテゴリを追加し、その後
UIMutableUserNotificationCategory *newNotificationCategory = [[UIMutableUserNotificationCategory alloc] init];
newNotificationCategory.identifier = @"no_button_id";
を:
NSMutableArray *arrNewCategories = [NSMutableArray new];
UIUserNotificationSettings *oldSettings = [[UIApplication sharedApplication]currentUserNotificationSettings];
for (UIMutableUserNotificationCategory *oldCategory in oldSettings.categories)
{
if (![oldCategory.identifier isEqualToString:newNotificationCategory.identifier])
[arrNewCategories addObject:oldCategory];
}
[arrNewCategories addObject:newNotificationCategory];
UIUserNotificationType notificationType = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *newSettings = [UIUserNotificationSettings settingsForTypes:notificationType categories:[NSSet setWithArray:arrNewCategories]];
[[UIApplication sharedApplication] registerUserNotificationSettings:newSettings];
だけnewNotificationCategoryの識別子があなたと一致することを確認してくださいあなたがボタンを必要としないUILocalNotificationのカテゴリ。インタラクティブ通知として
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:afireDate];
localNotification.alertBody = @"alert body text";
localNotification.category = @"no_button_id"; // Same as category identifier
localNotification.timeZone = [NSTimeZone systemTimeZone];
localNotification.soundName = SOUND_FILE;
localNotification.repeatInterval = 0;
[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];
+0
これは正しい方法です!ありがとう兄貴 – iTSangar
関連する問題
- 1. プッシュ通知からのプッシュ表示
- 2. プッシュ通知でメッセージ本文を表示
- 3. イオン表示でプッシュ通知を表示3
- 4. クロムプッシュ通知:非表示のプッシュを送信
- 5. 非表示 - 表示ボタン
- 6. Windowsの対話型通知
- 7. appcelerator - 対話型通知
- 8. Android - GCMプッシュ通知が通知リストに表示されない
- 9. ムービープレーヤーコントロールが表示/非表示になったときの通知?
- 10. アンドロイド通知バーの表示/非表示切り替え
- 11. 剣道通知ウィジェット複数回表示と非表示
- 12. HTMLメールの非表示/表示ボタン
- 13. jQueryの表示/非表示ボタン
- 14. の表示/非表示ボタンが
- 15. ボタンの表示/非表示方法は?
- 16. 通知をプッシュしてボタン操作を表示する[iphone sdk APNS]
- 17. 通知ビューの対話アクションがiOS 10(xcode 8)で表示されない
- 18. Ionic2 - コントローラの表示方法に基づいて表示/非表示ボタン
- 19. 表示後に通知センターでプッシュ通知を削除する方法
- 20. プッシュ通知にカスタマイズされた通知が表示されない
- 21. Jqueryダイアログ:ボタンを非表示
- 22. SAPUI5ウィザード:通知を表示
- 23. モトローラアクティブディスプレイの通知を表示
- 24. javacriptで通知を表示
- 25. コロナSDK表示マルチライン通知
- 26. ブラックベリープッシュ通知を表示
- 27. MirrorLinkの表示通知
- 28. iOS 11でキーボードの表示/非表示通知センターが動作しない
- 29. プッシュ通知のFirebaseオープンレートはデータを表示しません
- 30. エンドポイントのGoogle Pub/Subプッシュ通知が表示されない
notification.category = "値" アクト:
そして通知をスケジュールします。 without without notification.category = "value"通常のローカル通知として動作します。 –