2017-11-02 9 views
-1

iOSリマインダーアプリと同じようにアプリを作りたいです。私の問題はカスタムリピートパートです。 「3月曜日に2ヶ月ごと」(以下のスクリーンショット)のようなカスタムリピートを設定できますが、このようなリピートをユーザー通知で実装する方法はわかりません。Swift 3 - ユーザー通知iOSリマインダーアプリのようなカスタムリピート

どうすればよいですか?

screenshot

+0

は、これは私が使用することをお勧めしていないよ、それは実現するのは難しいあなたhttps://developer.apple.com/documentation/usernotifications –

+0

を助けるかもしれません。ただし、毎日、毎週、毎年、平日ごとに通知を設定できます。それはちょうど作品です – Mannopson

答えて

0

質問は答え完全する海外かもしれませんが、私はあなたがユーザーの通知を使用してそれを達成できるかの表面を傷つけるべきで答えを投稿します。

:、あなたは UNCalendarNotificationTriggerで動作するはずです - あなたは「第三月曜日に2ヵ月ごとに」言及-as

あなたは通知の表示をさせることを目指している場合は、特定の日付/時間間隔に基づいています

ローカル通知を配信する日時。

例:

import UserNotifications 

// first, you declare the content of the notification: 
let content = UNMutableNotificationContent() 
content.title = "Notification Title" 
content.subtitle = "Notification Subtitle" 
content.body = "Notification Body" 

// now, you should declare the UNCalendarNotificationTrigger instance, 
// but before that, you'd need to describe what's the date matching for firing it: 

// for instance, this means it should get fired every Monday, at 10:30: 
var date = DateComponents() 
date.weekday = 2 
date.hour = 10 
date.minute = 30 

// declaring the trigger 
let calendarTrigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true) 

// creating a request and add it to the notification center 
let request = UNNotificationRequest(identifier: "notification-identifier", content: content, trigger: calendarTrigger) 
UNUserNotificationCenter.current().add(request) 
関連する問題