2017-02-08 2 views
2

J'ai un problème de non-fonctionnement de la notification locale lorsque j'ai envoyé une mise à jour pour mon application. Je l'ai testé dans mon appareil et cela fonctionnait mais quand je télécharger l'application de l'AppStore la notification ne fonctionne pas du tout est le code ici est AppDelgate:La notification locale ne fonctionne pas lorsque l'application de soumission est dans l'App Store

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]) 
    } 

et je l'ai mis en œuvre ce code pour envoyer une notification lorsque la a frappé la minuterie a frappé le jour de la sortie

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 
      } 

J'espère que quelqu'un peut me aider j'ai essayé toutes les solutions mais n'a toujours pas de travail pour les utilisateurs, sauf mon appareil de développement

+0

S'il vous plaît laissez-nous savoir ce qui se passe exactement "ne fonctionne pas du tout" et quelle version iOS le fonctionnement et les appareils qui ne fonctionnent pas sont en cours d'exécution. – shallowThought

+0

@shallowThought ne fonctionne pas du tout, toutes les versions comprennent ios 10 –

+0

tout le monde peut aider s'il vous plaît avec ce numéro –

Répondre

0

d'émission avec délégué de notification et vérifier l'heure et la date pour la notification