में अग्रभूमि में स्थानीय अधिसूचना क्या स्थानीय अधिसूचना तब दिखाई देगी जब ऐप अग्रभूमि में है और वर्तमान में आईफोन एसडीके में चल रहा है?आईफोन एसडीके
उत्तर
नहीं, आपको एपडिलेगेट में अधिसूचना प्राप्त होगी।
- (void) application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification {
//Place your code to handle the notification here.
}
निम्नलिखित समारोह अपने प्रतिनिधि को बुलाया कि आपके ऐप में अग्रभूमि में है जाएगा:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)Notifikation
आप तो एक alertview दिखाने के लिए तय कर सकते हैं, लेकिन मानक एक अपने आप में दिखाई नहीं देंगे
इस पर ध्यान दिए बिना कि ऐप पहले से चल रहा था या नहीं। –
केवल तभी जब उपयोगकर्ता "खुला" बटन पर क्लिक करता है ... – Bastian
मैंने स्थानीय अधिसूचना के समान ही एनीमेशन बनाने के लिए एक lib बना दिया।
चेक करें: https://github.com/OpenFibers/OTNotification
डेमो:
और तुम जब आप
- (void) application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification
{
OTNotificationManager *notificationManager = [OTNotificationManager defaultManager];
OTNotificationMessage *notificationMessage = [[OTNotificationMessage alloc] init];
notificationMessage.title = [self notificationTitle];
notificationMessage.message = @"A notification. Touch me to hide me.";
[notificationManager postNotificationMessage:notificationMessage];
}
का इन एक संदेश प्राप्त हुआ इस lib लिए एक नया संदेश पोस्ट कर सकते हैं स्वीकृत उत्तरकर्ता सही है, लेकिन यह पर्याप्त टी नहीं है ओ सभी सूचनाएँ प्राप्त और से
- (void) application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification {
आप की जाँच करने के लिए है उपयोगकर्ता के लिए कुछ दिखाने के लिए, यह वर्तमान अधिसूचना या नहीं है। कभी-कभी अन्य सूचनाएं आग लगती हैं (उदाहरण के लिए, जब आप उन्हें रद्द करते हैं)।
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
if (fabs([[NSDate date] timeIntervalSinceDate:[notification fireDate]]) <= 0.5f)
{
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Notification alert", @"")
message:notification.alertBody
delegate:self
cancelButtonTitle:@"Ok" otherButtonTitles:nil] show];
}
}
स्विफ्ट 2.2:: तो, आप की जाँच करने के लिए है, कि क्या आप को छोड़कर है
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
var state = application.applicationState
if state == .Active {
// handle the notification, e.g. show an alert
}
}
स्विफ्ट 3.0:
func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
var state: UIApplicationState = application.applicationState
if state == .active {
// handle the notification, e.g. show an alert
}
}
धन्यवाद एक बहुत। अब, मैंने एप्लिकेशन में UIAlertView रखा है रीसीव लॉकलोटेशन विधि ताकि मैं इसे पहले से चलने पर अधिसूचना के स्थान पर उपयोग कर सकूं। लेकिन जब ऐप पृष्ठभूमि में होता है और अधिसूचना निकाल दी जाती है और जब ऐप अग्रभूमि में आता है, तो इस विधि को बुलाया जाता है और वह चेतावनी दृश्य आता है। क्या आप मुझे बता सकते हैं कि मैं इससे कैसे बच सकता हूं। –
ठीक है हमारे पास एप्लिकेशन है IillEnterForeground: इसके लिए विधि। क्षमा करें बेवकूफ सवाल! बहुत बहुत धन्यवाद। –
कोई बेवकूफ सवाल नहीं - आपने मुझे वह जवाब दिया जो मैं ढूंढ रहा था :-) –