2017-02-08 5 views
2

アプリのアップデートを送信したときにローカル通知が機能しないという問題があります。アプリストアにアプリを送信するとローカル通知が機能しない

class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDelegate 

@available(iOS 10.0, *) 
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) { 

    } 
    @available(iOS 10.0, *) 
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { 
     completionHandler([.alert,.sound]) 
    } 

と私はときに通知を送信するには、このコードを実装している:私は私のデバイスで実行テストして、それが働いていたが、私は、AppStoreからアプリをダウンロードするときに通知がここにすべての で働いていないコードがAppDelgateされていますタイマーヒットは、私は誰かが私はすべてのソリューションを試してみましたが、まだ通知デリゲートと私の現像装置

+0

「正常に動作していません」と動作中のデバイスと動作していないデバイスが動作しているiOSのバージョンをお知らせください。 – shallowThought

+0

@shallowThoughtはまったく動作しません。すべてのバージョンにios 10 –

+0

誰でもこの問題をお寄せください –

答えて

0

問題以外のユーザーのために働いていなかった私を助けることを願ってリリース

import UserNotifications 
    let center = UNUserNotificationCenter.current() 
     let options : UNAuthorizationOptions = [.alert, .sound, .badge] 

      center.requestAuthorization(options: options) { (granted, error) in 
       if !granted { 
        print("Somthing went wrong") 

       } 
      } 

      center.getNotificationSettings { (settings) in 
       if settings.authorizationStatus != .authorized { 
        print("Notification not allowd") 
       } 
      } 

    here is in different function that calculate the time and send notification, I have not put the code for timer to make it more visual for others 


    let content = UNMutableNotificationContent() 
       content.title = NSLocalizedString("NOTIFICATION_TITLE", comment: "Game Released") 
       content.body = "\(self.currentGame.gameName) Released ✌" 
       content.sound = UNNotificationSound.default() 

       let date = dateFormatter.date(from: currentGame.gameDate) 
       let triggerDate = Calendar.current.dateComponents([.year,.month,.day,.hour,.minute,.second], from: date!) 
       let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: false) 
       let indetifier = "UYLLocalNotification" 
       let request = UNNotificationRequest(identifier: indetifier, content: content, trigger: trigger) 
       center.add(request, withCompletionHandler: { (error) in 
        if error != nil{ 
         print("Something went wrong here ") 

        } 
       }) 


      } 
      else { 
       gamesCountdownLabel.text! = countdownText 
      } 

の日を打ちますとお知らせの日時を確認してください

関連する問題