한국어

Coding

온누리070 플레이스토어 다운로드
    acrobits softphone
     온누리 070 카카오 프러스 친구추가온누리 070 카카오 프러스 친구추가친추
     카카오톡 채팅 상담 카카오톡 채팅 상담카톡
    
     라인상담
     라인으로 공유

     페북공유

   ◎위챗 : speedseoul


  
     PAYPAL
     
     PRICE
     

pixel.gif

    before pay call 0088 from app


글 수 101

https://stackoverflow.com/questions/37938771/uilocalnotification-is-deprecated-in-ios10


39

It may be a question in advance but I wonder what to use instead of UILocalNotification in iOS10. I am working on an app which has deployment target iOS8 so will it be ok to use UILocalNotification?

98

Yes, you can use UILocalNotification, old APIs also works fine with iOS10, but we had better use the APIs in the User Notifications framework instead. There are also some new features, you can only use with iOS10 User Notifications framework.

This also happens to Remote Notification, for more information: Here.

New Features:

  1. Now you can either present alert, sound or increase badge while the app is in foreground too with iOS 10
  2. Now you can handle all event in one place when user tapped (or slided) the action button, even while the app has already been killed.
  3. Support 3D touch instead of sliding gesture.
  4. Now you can remove specifical local notification just by one row code.
  5. Support Rich Notification with custom UI.

It is really easy for us to convert UILocalNotification APIs to iOS10 User Notifications framework APIs, they are really similar.

I write a Demo here to show how to use new and old APIs at the same time: iOS10AdaptationTips .

For example,

With Swift implementation:

  1. import UserNotifications

    ///    Notification become independent from UIKit
    import UserNotifications
  2. request authorization for localNotification

        let center = UNUserNotificationCenter.current()
        center.requestAuthorization(options: [.alert, .sound]) { (granted, error) in
            // Enable or disable features based on authorization.
        }
  3. schedule localNotification

  4. update application icon badge number

    @IBAction  func triggerNotification(){
        let content = UNMutableNotificationContent()
        content.title = NSString.localizedUserNotificationString(forKey: "Elon said:", arguments: nil)
        content.body = NSString.localizedUserNotificationString(forKey: "Hello Tom!Get up, let's play with Jerry!", arguments: nil)
        content.sound = UNNotificationSound.default()
        content.badge = UIApplication.shared().applicationIconBadgeNumber + 1;
        content.categoryIdentifier = "com.elonchan.localNotification"
        // Deliver the notification in 60 seconds.
        let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 60.0, repeats: true)
        let request = UNNotificationRequest.init(identifier: "FiveSecond", content: content, trigger: trigger)
    
        // Schedule the notification.
        let center = UNUserNotificationCenter.current()
        center.add(request)
    }
    
    @IBAction func stopNotification(_ sender: AnyObject) {
        let center = UNUserNotificationCenter.current()
        center.removeAllPendingNotificationRequests()
        // or you can remove specifical notification:
        // center.removePendingNotificationRequests(withIdentifiers: ["FiveSecond"])
    }

Objective-C implementation:

  1. import UserNotifications

    // Notifications are independent from UIKit
    #import <UserNotifications/UserNotifications.h>
  2. request authorization for localNotification

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert)
                          completionHandler:^(BOOL granted, NSError * _Nullable error) {
                              if (!error) {
                                  NSLog(@"request authorization succeeded!");
                                  [self showAlert];
                              }
                          }];
  3. schedule localNotification

  4. update application icon badge number

    UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
    content.title = [NSString localizedUserNotificationStringForKey:@"Elon said:"
                                                        arguments:nil];
    content.body = [NSString localizedUserNotificationStringForKey:@"Hello Tom!Get up, let's play with Jerry!"
                                                       arguments:nil];
    content.sound = [UNNotificationSound defaultSound];
    
    // 4. update application icon badge number
    content.badge = [NSNumber numberWithInteger:([UIApplication sharedApplication].applicationIconBadgeNumber + 1)];
    // Deliver the notification in five seconds.
    UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger
                                                triggerWithTimeInterval:5.f
                                                repeats:NO];
    UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"FiveSecond"
                                                                        content:content
                                                                        trigger:trigger];
    /// 3. schedule localNotification
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
        if (!error) {
            NSLog(@"add NotificationRequest succeeded!");
        }
    }];

Go to here for more information: iOS10AdaptationTips.

updated

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'time interval must be at least 60 if repeating'

let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 60, repeats: true)
  • You are missing argument name in "center.requestAuthorization([.alert, .sound])", it should be " center.requestAuthorization(options: [.alert, .sound])" – MQoder Sep 20 '16 at 9:52
  • I have this set up in my app exactly as written above. The notification only appeared one time. I ran it again with a different notification and now I dont receive any notifications. Any ideas? – Nate4436271 Oct 19 '16 at 18:37
  • @MQoder I‘ve updated the answer. – ElonChan Oct 26 '16 at 3:50 
  • @Nate4436271 I‘ve updated the answer. – ElonChan Oct 26 '16 at 3:50
  • 2
    @Zennichimaro: you can implement both UILocalNotification (iOS 9) and UNNotificationRequest(iOS 10) in your code. Use this to test which iOS is running: if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber10_0) { \\ run iOS 10 code } else { // run iOS 9 code } – KoenJan 22 '17 at 15:57
8

Apple have done it again, the correct implementation is: AppDelegate.swift

if #available(iOS 10.0, *) {
        let center = UNUserNotificationCenter.currentNotificationCenter()
        center.requestAuthorizationWithOptions([.Alert, .Sound]) { (granted, error) in
            // Enable or disable features based on authorization.
        }
    } else {
        // Fallback on earlier versions
    }

and don't forget to add

import UserNotifications
2

Local Notifications for iOS 10 in Objetcive-C

If you are programming for a while I am sure you are familiar with the UILocalNotification class, and right now with the arriving of iOS 10 you can see that UILocalNotification is been deprecated. For a detailed implementation visit this blog post

https://medium.com/@jamesrochabrun/local-notifications-are-a-great-way-to-send-notifications-to-the-user-without-the-necessity-of-an-b3187e7176a3#.nxdsf6h2h

1

swift 4

if #available(iOS 10.0, *) {
        let center = UNUserNotificationCenter.current()
        center.requestAuthorization(options: [.alert, .badge, .sound])  { (granted, error) in
            // Enable or disable features based on authorization.
        }
    } else {
        // REGISTER FOR PUSH NOTIFICATIONS
        let notifTypes:UIUserNotificationType  = [.alert, .badge, .sound]
        let settings = UIUserNotificationSettings(types: notifTypes, categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
        application.applicationIconBadgeNumber = 0

    }

MARK: - DELEGATES FOR PUSH NOTIFICATIONS

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let installation = PFInstallation.current()
    installation?.setDeviceTokenFrom(deviceToken)
    installation?.saveInBackground(block: { (succ, error) in
        if error == nil {
            print("DEVICE TOKEN REGISTERED!")
        } else {
            print("\(error!.localizedDescription)")
        }
    })
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    print("application:didFailToRegisterForRemoteNotificationsWithError: %@", error)
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    print("\(userInfo)")

    // PFPush.handle(userInfo)
    if application.applicationState == .inactive {
        PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(inBackground: userInfo, block: nil)
    }
}

번호
제목
글쓴이
101 아이폰 카톡 푸시 알림이 안올때! 상세안내 체크
admin
24355   2019-01-10
 
100 mac OS 여러가지 맥 버젼 별 설명 구분 시에라 까지
admin
14077   2018-05-11
 
99 오브젝트의 해방
admin
12580   2018-06-01
 
98 재정
admin
10655   2018-06-01
 
97 What is a Composite Object? objective c 강의 사이트 아주 훌륭한 유익한 좋은
admin
10005   2019-05-22
 
96 CallKit Tutorial for iOS 콜킷 사용
admin
9990   2019-04-02
 
95 Apple iPhone XS Max 셀룰러 데이터가 작동하지 않는 문제 해결 가이드
admin
9899   2018-11-09
 
94 IOS 앱이 시스템 수준 전화 통합을 위해 CallKit을 사용하는 방법과 통화
admin
9037   2019-04-02
 
93 iPhone XS Max 시스템 가이드 소프트 강제 재시작 모든 설정 네트워크 설정 초기화
admin
8818   2018-11-08
 
92 iOS 인증서 및 프로비저닝 프로파일 만들기
admin
8481   2019-04-04
 
91 Voice Over IP (VoIP) Best Practices Xcode
admin
8413   2019-04-19
 
90 PushKit이란 ? 푸시 알람을 앱에 보내는 것
admin
8057   2019-04-08
 
89 VMWare를 이용한 mac os를 설치방법
admin
7650   2018-05-11
 
88 Easy APNs Provider 사용방법 iOS Push발송 테스트
admin
7407   2019-04-23
 
87 iOS Notification 만들기 push 푸시
admin
7361   2019-04-04
 
86 Apple iPhone XS Max 작동하지 않는 얼굴 ID를 수정하는 방법 문제 해결 가이드
admin
7238   2018-11-09
 
85 Xcode 글꼴 크기 변경
admin
7163   2019-05-25
 
84 Apple iPhone XS Max 배터리가 빨리 소모되면 어떻게해야합니까? 문제 해결 가이드 및 배터리 절약 팁
admin
6843   2018-11-09
 
83 iPhone XS Max를 문제 해결, iPhone 과열 문제 해결 [문제 해결 가이드]
admin
6655   2018-11-09
 
82 [프로그래밍]아이폰 SDK와 Xcode 통합 개발환경
admin
6470   2018-06-01
 
81 [프로그래밍]Objective-C 셀렉터(@selector)
admin
6409   2018-06-01
 
80 클래스의 선언과 정의
admin
6408   2018-06-01
 
79 APNs 애플 푸시 앱 개발 push 키 등록 만들기 가장 잘된 동영상 설명
admin
6366   2019-04-08
 
78 작동하지 않는 Apple iPhone XS Max 마이크를 해결 방법 문제 해결 가이드
admin
6313   2018-11-09
 
77 Objective-C는?
admin
6293   2018-06-01
 
76 가져 오기
admin
6274   2018-06-01
 
75 IOS12 업데이트 후 작동하지 않는 Apple iPhone X 알림 수정 방법
admin
6269   2018-11-08
 
74 매우 천천히 반응하는 Apple iPhone XS Max 터치 스크린을 수정하는 방법, 터치 스크린 응답 지연됨 문제 해결 가이드
admin
6255   2018-11-09
 
73 메소드
admin
6244   2018-06-01
 
72 Apple iPhone XS Max에서 지속적으로 충돌하는 응용 프로그램을 수정하는 방법 문제 해결 가이드
admin
5957   2018-11-09
 
71 이니셜 라이저
admin
5920   2018-06-01
 
70 Sample app in Swift Objective C receive VoIP push notifications 푸시 테스트 앱
admin
5847   2019-04-19
 
69 상속
admin
5829   2018-06-01
 
68 가시성
admin
5823   2018-06-01
 
67 Objective-C (전역) 상수 선언 및 사용
admin
5822   2019-05-18
 
66 Objective-C 입문
admin
5806   2018-06-01
 
65 VoIP Push Notifications using iOS Pushkit
admin
5788   2019-04-08
 
64 애플 개발자 사이트 apple 앱스토어에 앱을 등록하는 순서
admin
5783   2019-03-24
 
63 프로토콜
admin
5776   2018-06-01
 
62 메소드의 포인터
admin
5774   2018-06-01
 
61 클래스 형
admin
5768   2018-06-01
 
60 클래스 메소드
admin
5743   2018-06-01
 
59 정적 형식
admin
5729   2018-06-01
 
58 IPad Air와 iPad Pro의 차이점
admin
5700   2018-11-08
 
57 선택기
admin
5697   2018-06-01
 
56 카테고리
admin
5694   2018-06-01
 
55 HybridApp Cordova 코르도바 란
admin
5651   2019-04-15
 
54 IPHONE 아이폰 푸쉬 노티피케이션 동작 안되는 현상 해결방법
admin
5632   2018-11-08
 
53 푸시 알림을 수신하려면 응용 프로그램이 Apple 푸시 알림 서비스 APN
admin
5619   2019-01-10
 
52 iOS Application 개발 시작하기 프로비저닝 생성, XCode 프로젝트 설정
admin
5591   2019-04-25
 
51 Push Notifications by Tutorials iOS developers
admin
5587   2019-04-19
 
50 맥 모하비 설치 VM Vmware Workstation Pro 15 설치 ebay 싸게구매
admin
5576   2019-03-23
 
49 Mac용 키체인 접근이란 무엇입니까?
admin
5536   2019-04-04
 
48 아이폰 푸시 노티피케이션 온/오프
admin
5503   2018-11-08
 
47 Apple Push Notification Service 시작하기 AWS 샘플앱 이용 푸시 테스트
admin
5493   2019-04-04
 
46 iOS Application 개발 시작하기 개발자 등록, 등록요청서 , 인증서 다운
admin
5403   2019-04-25
 
45 Xcode 9, Swift 4 Remote Push Notification Setup W/ Firebase
admin
5399   2019-04-08
 
44 맥 개발 환경 설정하기
admin
5368   2019-04-01
 
43 Push Notifications and Local Notifications – Tutorial
admin
5347   2019-04-19
 
42 iOS Beginner : Messaging & Phone call (Swift 4 & Xcode 9)
admin
5315   2019-04-01
 
41 MacPorts to use system for compiling, installing, and managing open source software. file
admin
5305   2019-04-01
 
40 아이폰 UserNotifications 사용법
admin
5284   2019-04-08
 
39 MacPorts 설치 및 사용법
admin
5280   2019-04-01
 
38 Push Notifications and Local Notifications (Xcode 9, iOS 11)
admin
5275   2019-04-19
 
37 hide/show text fields with auto layouts and programmatically objective c
admin
5269   2019-05-19
 
36 아이폰 VoIP Services Certificate 생성 방법 - 서비스 인증서 생성하는 방법
admin
5259   2019-04-08
 
35 개발자 등록 인증서 다운로드 푸시 인증요청서 등록 인증서 다운
admin
5241   2019-04-27
 
UILocalNotification is deprecated in iOS10
admin
5239   2019-04-08
https://stackoverflow.com/questions/37938771/uilocalnotification-is-deprecated-in-ios10 Ask Question 39 24 It may be a question in advance but I wonder what to use instead of UILocalNotification in iOS10. I ...  
33 애플앱개발 앱스토어등록 개발자사이트등록 앱튠스콘넥트사이트등록
admin
5233   2019-03-24
 
32 IPAD IPHONE X 아이패드 아이폰 전문가 리뷰 트러블슈팅 문제해결
admin
5224   2018-11-08
 
31 OSX 키체인접근 p12 파일 인증서, 개인키를 PEM 파일로 openssl
admin
5187   2019-04-08
 
30 APNS 또는 GCM 사용을 위한 앱 구성 방법 순서
admin
5175   2019-04-06
 
29 Part 2: Implementing PushBots SDK for your iOS App
admin
5168   2019-04-08
 
28 installing MacPorts on macOS Sierra (plus installing ffmpeg)
admin
5128   2019-04-01
 
27 How to create Apple Certificates - Step 1: CSR file creation CSR 생성
admin
5123   2019-04-19
 
26 Homebrew 설치 (MacOSX) 동영상
admin
5100   2019-04-01
 
25 iOS12 Chat, Learn Swift 4.2, build iOS 12 Chat Application 스터디
admin
5083   2019-04-03
 
24 Enhancing VoIP Apps with CallKit - Apple WWDC 2016 콜킷
admin
5082   2019-04-02
 
23 How to rename Xcode project
admin
5078   2019-04-08
 
22 MacPort 의 소개와 간단 사용법 - OSX 환경 세팅하기
admin
5074   2019-04-01
 
21 Part 1: Preparing Certificates + Provisioning Profile (iOS)
admin
5039   2019-04-08
 
20 포인터에 익숙해지기 포인터 정리
admin
5020   2019-01-20
 
19 개발자를 위한 맥(Mac) 정보 - 패키지관리자 Homebrew
admin
4956   2019-04-01
 
18 How to rename an XCode project
admin
4942   2019-04-20
 
17 [아이폰] PushKit 앱 개발 방법
admin
4924   2019-04-08
 
16 사용자 정의 컨테이너보기 컨트롤러 전환 xcode objective c
admin
4819   2019-05-25
 
15 ios 개발자 계정 만들기 지불 방법 핵심 키포인트 인증서요청 앱등록 앱출시 요점만 쉽게 설명
admin
4803   2019-04-17
 
14 Mac OS X에서 Java(JDK) 설치 및 삭제하기
admin
4752   2019-04-03
 
13 IOS Push php
admin
4725   2019-04-20
 
12 Objective-c JSON Parsing 제이슨 파싱 Dictionary Array 구분 기호
admin
4627   2019-06-06
 
11 ios push notification pushkit xcode swift
admin
4621   2019-04-08
 
10 푸시 메시지를 활성화하기 위한 전제 조건 사전작업
admin
4600   2019-04-06
 
9 Linphone rebuild
admin
4598   2019-04-09
 
8 실습 Objective C Code 연습 실행 온라인 무료 사이트 회원가입 불필요 광고 무
admin
4562   2019-05-22
 
7 푸시 메시지 구성
admin
4555   2019-04-06
 
6 A macOS, Linux, Windows app to test push notifications on iOS and Android
admin
4520   2019-04-19
 
5 키체인 uuid keychaine 설명 및 사용
admin
4511   2019-04-29
 
4 Text field 숨기기
admin
4496   2019-05-19
 
3 Segue를 통한 뷰 컨트롤러 전환과 데이터 교환 방법. Delegate 가장 정확하게 설명 쉽게
admin
4457   2019-05-21
 
2 초보) delegate 는 왜필요한가 이것만알면 간단 쉽게 이해 objective C 날로먹기가능
admin
4411   2019-05-22