मैं निर्धारित समय पर एक स्थानीय अधिसूचना भेजने की कोशिश कर रहा हूं। लेकिन अधिसूचना स्क्रीन पर दिखाई नहीं देती है, लेकिन जब मैं स्वाइप करता हूं तो यह अधिसूचना केंद्र में दिखा रहा है।
यही वह है जिसे मैं प्राप्त करने की कोशिश कर रहा हूं यह मुझे मिल रहा है।
आईओएस स्विफ्ट स्थानीय अधिसूचना "पॉपिंग अप" नहीं
इस कोड मेरे AppDelegate की didFinishLaunchingWithOptions से है()।
// Setup local push notifications
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound], categories: nil))
scheduleNotifications()
और यह() scheduleNotifications के लिए कोड
func scheduleNotifications() {
// create a corresponding local notification
let notification = UILocalNotification()
// Get today's date, time and year
let calendar = NSCalendar.currentCalendar()
let components = calendar.components([NSCalendarUnit.Day, NSCalendarUnit.Month, NSCalendarUnit.Year], fromDate: NSDate())
// Sets the fire time to 2pm/1400 hours to anticipate user for lunch time
components.hour = 19
components.minute = 13
components.second = 00
notification.fireDate = components.date // Sets the fire date
notification.alertBody = "Enjoyed your lunch? Don't forget to track your expenses!"
notification.alertAction = "Add expense"
notification.repeatInterval = NSCalendarUnit.Day // Repeats the notifications daily
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
किसी भी मदद की सराहना की होगी। धन्यवाद!
में आईओएस सेटिंग्स में दस्तावेज किया गया है> आपकी ऐप अनुमति सेटिंग्स सही हैं? विशेष रूप से, 'लॉक स्क्रीन पर दिखाएं' के लिए सेटिंग की जांच करें। साथ ही, क्या आप पुश अधिसूचना के साथ भेज रहे पेलोड को पोस्ट कर सकते हैं। – JoGoFo
हां लॉकस्क्रीन पर दिखाने के लिए सेट है। और पेलोड द्वारा आपका क्या मतलब है? नोटिफिकेशन के लिए मैंने लिखा यह सब कोड है। –
क्षमा करें, स्थानीय अधिसूचना के बजाय पुश अधिसूचना के बारे में सोच रहा था, जिसमें एक पेलोड है। क्या आप भविष्य में काफी समय तक शेड्यूल कर रहे हैं ताकि अधिसूचना प्राप्त हो सके _after_ आप डिवाइस को लॉक कर सकते हैं? – JoGoFo