私はサイレントローカルプッシュ通知を実装する方法を探しています。そのユーザーが範囲外であるときに、私は静かな通知をユーザーに送信したい。iOSサイレントローカルプッシュ通知の目的c?
答えて
解決済み。 ローカル通知を作成するときに、次の値を設定しないでください。このような
notification.alertBody = message;
notification.alertAction = @"Show";
notification.category = @"ACTION";
notification.soundName = UILocalNotificationDefaultSoundName;
だけクレートローカル通知:
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate date];
NSTimeZone* timezone = [NSTimeZone defaultTimeZone];
notification.timeZone = timezone;
notification.applicationIconBadgeNumber = 4;
[[UIApplication sharedApplication]scheduleLocalNotification:notification];
これは、ローカル通知を送信するだけでアプリがバックグラウンドで動作しているとき、いかなる通知を通知センターに表示されません4としてIconBadgeNumber表示されます。 ViewController
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNMutableNotificationContent *content = [UNMutableNotificationContent new];
//content.title = @"Don't forget";
//content.body = @"Buy some milk";
//content.sound = [UNNotificationSound defaultSound];
content.badge = [NSNumber numberWithInt:4];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:15 repeats:NO];
NSString *identifier = @"UniqueId";
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
content:content trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Something went wrong: %@",error);
}
}];
で
iOS10ため更新(UNUserNotificationCenter)
AppDelegate で
@import UserNotifications;
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNAuthorizationOptions options = UNAuthorizationOptionAlert + UNAuthorizationOptionSound + UNAuthorizationOptionBadge;
[center requestAuthorizationWithOptions:options
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!granted) {
NSLog(@"Something went wrong");
}
}];
これは4
としてバッジカウントで15秒後にサイレント通知を送信しますこんにちは@Ruturaj Desai:働いてくれてありがとうございます。しかし、私はUNUserNotificationCenterを使ってiOS 10と似ている必要があります。何か考えてください。 – Ammaiappan
こんにちは@Ammaiappan、私はiOS 10(UNUserNotificationCenter)のための私の答えを更新しました。これはあなたを助けるかもしれません。ハッピーコーディング。 –
こんにちは@Ruturaj Desai、私は同じことを試み、アプリケーションがフォアグラウンドでは完璧ですが、バックグラウンドでは動作しません。バックグラウンドを回避する方法はありますか? –
- 1. iOS 10のプッシュ通知を実装する方法[目的C]?
- 2. iOS目的C:ユーザーがスペースバーをタップしたときの通知方法
- 3. iOS目的のマルチスレッドC
- 4. 動的ロケーションベースのローカル通知Swift iOS
- 5. iOSの通知
- 6. iOSのAzure Mobile App通知ハブで目的のプッシュ通知に登録する方法
- 7. 目的C-Push通知がCloudkitと連携していない
- 8. アクセス先iOS目的c
- 9. iOS永続的通知/クイック起動
- 10. iOSアプリのEmoji - 通知/通知 - Xcode/Swift
- 11. swift 2:目的-cとは対照的にプッシュ通知の代理コールバックなし
- 12. iOS CoreBluetooth通知
- 13. iOsプッシュ通知
- 14. iOS通知(バックグラウンド)
- 15. サイレントプッシュ通知。 iOS
- 16. iOSリピートプッシュ通知
- 17. ローカル通知IOS
- 18. iOSのプッシュ通知
- 19. iOSのオフライン通知
- 20. iOS通知のローカライズ?
- 21. 目的のシリアル通信エラー-C:リソースビジー
- 22. 目的のCとピアツーピア通信
- 23. iOSプッシュ通知カスタムサウンドリピート?
- 24. iOSプッシュ通知(iP6)
- 25. iOSプッシュ通知ディスプレイ
- 26. iOSプッシュ通知フィードバックサービス
- 27. iOSとローカル通知
- 28. ポストマン - Firebase通知IOS
- 29. iOSバックグラウンドタスク/プッシュ通知
- 30. iOSプッシュ通知フロー
ありません。サイレントローカル通知。 – Paulw11
あなたが沈黙と言うとき、あなたはどういう意味ですか?あなたは音を避けたいですか?これをさらに説明してください。この質問は広すぎます。 – dokun1
@ dokun1リモートのサイレント通知のようにバックグラウンドで動作する通知を送信しようとしています。ユーザーは通知センターで通知を表示しません。 –