ringcentral / engage-digital-messaging-ios

Engage Digital Messaging IOS SDK
Other
10 stars 6 forks source link

Je ne reçois pas les notifications #24

Closed InesBokri closed 6 years ago

InesBokri commented 6 years ago

Bonjour,

Je viens d'implementer Dimelo mais je ne reçois pas la notification de message. Voici mon code que j'ai implémenté (en swift). Est ce que ca peut etre a cause de P8 communiqué? est ce qu'il faut fournir un P8 pour PROD et un P8 pour DEV?

// DimeloDelegate
func dimeloDisplayChatViewController(_ dimelo: Dimelo!) {

    let vc: UIViewController? = Dimelo.sharedInstance().chatViewController()
    vc?.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.closeChat))
    if UIDevice.current.userInterfaceIdiom == .pad {
        vc?.modalPresentationStyle = .formSheet
    }
    vc?.modalPresentationStyle = .overCurrentContext
    self.present(vc!, animated: true, completion: {() -> Void in
    })

}

@IBAction func closeChat(_ sender: Any) {
    self.dismiss(animated: true, completion: {() -> Void in
    })
}
func setupDimelo() {
    dimelo = Dimelo.sharedInstance().copy() as? Dimelo
    dimelo?.delegate = self
    dimelo?.developmentAPNS = true
    dimelo?.updateAppBadgeNumber = true
    dimelo?.interactiveNotification = true
    dimelo?.noteUnreadCountDidChange()
    dimelo?.title = " "

    let dimeloViewController = dimelo!.chatViewController

    dimeloViewController().navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.closeChat))
    addChildViewController(dimeloViewController())
    dimeloViewController().view.frame = CGRect.init(origin: view.frame.origin, size: view.frame.size)
    view.addSubview(dimeloViewController().view)

    dimeloViewController().didMove(toParentViewController: self)
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    // Register the device token.
    Dimelo.sharedInstance().deviceToken = deviceToken
}

func dimeloDidBeginNetworkActivity(_ dimelo: Dimelo?) {
    UIApplication.shared.isNetworkActivityIndicatorVisible = true
}

func dimeloDidEndNetworkActivity(_ dimelo: Dimelo?) {
    UIApplication.shared.isNetworkActivityIndicatorVisible = false
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    //! If notification is from Dimelo, you don't have to handle anything
    if Dimelo.sharedInstance().consumeReceivedRemoteNotification(userInfo) {
        return
    }
}
func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
    //! We simulate remote notification by putting its payload into a local notification.
    if Dimelo.sharedInstance().consumeReceivedRemoteNotification(notification.userInfo) {
        return
    }
        //! You app's handling of this notification.
}

func application(_ application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable : Any], withResponseInfo responseInfo: [AnyHashable : Any], completionHandler: @escaping () -> Void) {
        Dimelo.sharedInstance().handleRemoteNotification(withIdentifier: identifier, responseInfo: responseInfo)
        if completionHandler != nil {
            completionHandler()
        }
    //! Otherwise, here you app's handling of this notification.
    }

func updateBadge(withUnreadCount count: Int) {
    tabChatVC?.tabBarItem.badgeValue = count > 0 ? "\(count)" : nil
}

func updateUnreadCount() {
unreadUpdateTimer?.invalidate()
Dimelo.sharedInstance().fetchUnreadCount(completionHandler: {(_ unreadCount: Int, _ error: Error?) -> Void in
    if unreadCount == NSNotFound {
        print("error while updating unreadCount : \(error ?? "" as! Error)")
        if (error as NSError?)?.domain == DimeloHTTPErrorDomain && (error as NSError?)?.code == 429 {
            // 429 Too many requests. Be nice, add some delay.
            self.unreadFetchInterval += self.defaultUnreadFetchInterval
        }
    } else {
        self.updateBadge(withUnreadCount: unreadCount)
    }
    self.scheduleUnreadCountUpdateTimer()
})
}

func scheduleUnreadCountUpdateTimer() {
    unreadUpdateTimer?.invalidate()
    unreadUpdateTimer = Timer.scheduledTimer(timeInterval: unreadFetchInterval, target: self, selector: #selector(self.updateUnreadCount), userInfo: nil, repeats: false)
}
func dimeloUnreadCountDidChange(_ notification: Notification?) {
    updateBadge(withUnreadCount: Dimelo.sharedInstance().unreadCount)
    scheduleUnreadCountUpdateTimer()
}

Dans l'attente d'une réponse de votre part. Bien cordialement,

InesBokri commented 6 years ago

Bonjour,

J'ai fait la modification comme vous m'avez dit

dimelo?.developmentAPNS = false (au lieu de true) mais je ne reçois toujours pas les notifications. J'ai fait mes tests sur l'iphone et sur le simulateur de Xcode et toujours pas de notification : (

waelba commented 6 years ago

Bonjour @katasskatouss,

C'était un problème de notre part. Si vous pouvez refaire vos tests.

Remarques:

InesBokri commented 6 years ago

Bonjour Wael,

Oui enfin ca marche pour nous les notifications :) Merci pour votre réactivité pour vous et Cyrille! Reste que je veux envoyer le nom et prenom de l'utilisateur a vous et j'ai pas comment comment faire ca.

Merci.

waelba commented 6 years ago

Bonjour,

Vous pouvez utiliser le userName ou bien l'authenticationInfo dimelo.userName = "nom prénom" dimelo.authenticationInfo = ["key1": "value1", "key2": "value2"]

capture d ecran 2018-04-24 a 17 18 23

InesBokri commented 6 years ago

Merci pour votre réactivité!