पृष्ठभूमि या निष्क्रिय मोड में मेरा आवेदन तब स्थानीय अधिसूचना काम नहीं करती है। मुझे घड़ी पर स्थानीय अधिसूचना कभी नहीं मिली है।वॉचोस ऐप 4.0: स्थानीय अधिसूचना
अद्यतन: कम से कम 3 मिनट स्थानीय अधिसूचना शेड्यूल करते हैं, यह ठीक काम करता है लेकिन 3 मिनट से अधिक यह काम नहीं करता है। तो इन मुद्दों को कैसे हल करें?
मेरी समझ के अनुसार मेरा कोड इस प्रकार है।
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
// Objective-C
UNMutableNotificationContent *content = [UNMutableNotificationContent new];
content.title = [NSString localizedUserNotificationStringForKey:@"Remider!" arguments:nil];
content.body = [NSString localizedUserNotificationStringForKey:@"Your watch is out of range" arguments:nil];
content.sound = [UNNotificationSound defaultSound];
// Time
// 15 min
double timer = 15*60;
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:time
repeats:NO];
// Actions
UNNotificationAction *snoozeAction = [UNNotificationAction actionWithIdentifier:@"Track"
title:@"Track" options:UNNotificationActionOptionForeground];
// Objective-C
UNNotificationCategory *category = [UNNotificationCategory categoryWithIdentifier:@"UYLReminderCategory"
actions:@[snoozeAction] intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
NSSet *categories = [NSSet setWithObject:category];
// Objective-C
[center setNotificationCategories:categories];
// Objective-C
content.categoryIdentifier = @"UYLReminderCategory";
NSString *identifier = [self stringUUID];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
content:content trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Something went wrong: %@",error);
}
}];
कोई सुझाव या विचार की सराहना करें।
मैं यह जानता हूँ। मुझे वास्तविक डिवाइस पर परीक्षण किया गया था और मुझे घड़ी डिवाइस पर एक स्थानीय अधिसूचना अनुसूची नहीं मिली थी। –
मैंने 10 मिनट के अंतराल के साथ परीक्षण किया और यह काम किया। सुनिश्चित करें कि अधिसूचना निर्धारित की जा रही है। यदि ऐसा है, तो यह कहीं भी वितरित होना चाहिए, अगर घड़ी पर नहीं तो यह आईफोन होना चाहिए। – Muneeba
मैं आपके काम की सराहना करता हूं लेकिन मुझे यह ऐप वॉच ऐप पर चाहिए। घड़ी आवेदन के लिए कोई सुझाव या विचार? –