2017-11-06 24 views
6

पृष्ठभूमि या निष्क्रिय मोड में मेरा आवेदन तब स्थानीय अधिसूचना काम नहीं करती है। मुझे घड़ी पर स्थानीय अधिसूचना कभी नहीं मिली है।वॉचोस ऐप 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); 
    } 
}]; 

कोई सुझाव या विचार की सराहना करें।

उत्तर

0

सुनिश्चित करें कि आपका आईफोन लॉक है। जब अधिसूचना की बात आती है, तो इसकी प्राथमिकता कहां से दी जाती है।

सिम्युलेटर पर अधिसूचना अपनी घड़ी एप्लिकेशन चलाएं, iPhone सिम्युलेटर अनुसूची से और iPhone सिम्युलेटर स्क्रीन लॉक, घड़ी सिम्युलेटर सक्रिय रखने के लिए, उस मामले में जब अधिसूचना शुरू हो रहा है, यह अपनी घड़ी सिम्युलेटर पर वितरित किया जाएगा। वही होगा जब आप वास्तविक डिवाइस पर परीक्षण करेंगे। Source Link

और जब दोनों आईफोन और घड़ी लॉक हो जाते हैं, वरीयता आईफोन है।

अद्यतन

Notification on Apple Watch

+0

मैं यह जानता हूँ। मुझे वास्तविक डिवाइस पर परीक्षण किया गया था और मुझे घड़ी डिवाइस पर एक स्थानीय अधिसूचना अनुसूची नहीं मिली थी। –

+0

मैंने 10 मिनट के अंतराल के साथ परीक्षण किया और यह काम किया। सुनिश्चित करें कि अधिसूचना निर्धारित की जा रही है। यदि ऐसा है, तो यह कहीं भी वितरित होना चाहिए, अगर घड़ी पर नहीं तो यह आईफोन होना चाहिए। – Muneeba

+0

मैं आपके काम की सराहना करता हूं लेकिन मुझे यह ऐप वॉच ऐप पर चाहिए। घड़ी आवेदन के लिए कोई सुझाव या विचार? –

संबंधित मुद्दे