2017-07-31 69 views
-3

如何創建的在Objective-C本地通知this type自定義本地通知在Objective-C

+0

請放一些代碼。所以,回答者可以知道你爲此付出了哪些努力。 –

+0

http://prntscr.com/g2ds2r 我能夠創建像這樣的本地通知...我想知道如何定製它的用戶界面。 –

+1

你可以在下面的教程中看到Swift代碼。您需要爲Objective-c進行管理。 https://code.tutsplus.com/tutorials/ios-10-creating-custom-notification-interfaces--cms-27251 –

回答

0

其實,如果你正在建立一個本地通知,你是在具有圖像通知本身顯示有興趣,你不必與NotificationsUI.framework打擾

UNMutableNotificationContent *content = [UNMutableNotificationContent new]; 
    content.title = @"Title"; 
    content.body = @"Body"; 
    content.sound = [UNNotificationSound defaultSound]; 
    NSURL *imageURL = [NSURL URLWithString:@"file:/some/path/in/app/image.png"]; 
    NSError *error; 
    UNNotificationAttachment *icon = [UNNotificationAttachment attachmentWithIdentifier:@"image" URL:imageURL options:nil error:&error]; 
    if (error) 
    { 
     NSLog(@"error while storing image attachment in notification: %@", error); 
    } 
    if (icon) 
    { 
     content.attachments = @[icon]; 
    } 

然後當通知出現後,圖像將顯示在通知橫幅的右側,就像它對消息通知所做的一樣。並且您不必跳過設置帶類別標識符的內容擴展等的所有環節。

+0

其實我的要求是顯示通知,如附圖所示。 –