J'utilise Sinch avec Swift (avec en-tête de pontage) pour la messagerie instantanée et je ne reçois aucune notification push lorsqu'un message est reçu.Notification push iOS avec Sinch avec Swift
- J'ai un certificat de développement dans le tableau de bord Sinch.
- Les modes d'arrière-plan sont désactivés.
- Pousser le travail de notification avec d'autres voies (Pusher)
Mais quand j'envoie un message instantané sinch la fonction « didReceiveRemoteNotification » de délégué App ne sera jamais appelé.
var sinClient:SINClient?
var push:SINManagedPush?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Sinch Push Notification
sinClient = Sinch.client(withApplicationKey: "-----", applicationSecret: "------", environmentHost: "sandbox.sinch.com", userId: "----")
sinClient?.setSupportMessaging(true)
sinClient?.enableManagedPushNotifications()
sinClient?.delegate = self
sinClient?.messageClient().delegate = self
sinClient?.start()
sinClient?.startListeningOnActiveConnection()
self.push = Sinch.managedPush(with: SINAPSEnvironment.development)
self.push?.delegate = self
self.push?.setDesiredPushTypeAutomatically()
self.push?.registerUserNotificationSettings()
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
print("Device Token: \(token)")
self.push?.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
self.push?.application(application, didReceiveRemoteNotification: userInfo)
}
func managedPush(_ managedPush: SINManagedPush!, didReceiveIncomingPushWithPayload payload: [AnyHashable : Any]!, forType pushType: String!) {
sinClient?.relayRemotePushNotification(payload)
}
Les messages instantanés sont reçus uniquement lorsque j'ouvre l'application.
vous avez dit modes d'arrière-plan sont désactivés ... donc oui il ne sera reçu au premier plan. Si vous voulez que cela se produise lorsque l'application est en arrière-plan, vous devez activer ** background fetch ** voir [ici] (https://stackoverflow.com/questions/42275060/what-is-difference-between-remote-notification- et-silent-notification-in-ios/42302369 # 42302369) 1. Essayez-vous d'implémenter des notifications silencieuses ou des notifications à distance? 2. Savez-vous qu'il existe un nouveau framework 'UserNotifications' depuis iOS 10? Voir [ici] (https://stackoverflow.com/questions/37956482/registering-for-push-notifications-in-xcode-8-swift-3-0) – Honey
Salut @Honey merci pour votre aide, je suis en train de mettre en œuvre Notifications à distance pour Sinch, comme je l'ai dit je peux pousser la notification avec Pusher mais Sinch qui censé gérer la notification push à distance ne pousse pas une notification lorsque l'utilisateur reçoit un nouveau message (j'ai essayé d'activer l'extraction en arrière-plan, mais cela n'aide pas) –
1. Avez-vous également activé les "notifications à distance1" et "extraction d'arrière-plan"? Si ce n'est pas le cas, gardez les deux activés pour le moment ... 2. De plus, si vous êtes sur iOS 10 ... votre méthode 'didReceiveRemoteNotification' ne sera pas appelée. Voir [ici] (https://stackoverflow.com/q/39382852/5175709) – Honey