QuickBlox / quickblox-ios-sdk

QuickBlox iOS SDK for messaging and video calling
https://quickblox.com/developers/IOS
MIT License
396 stars 358 forks source link

Duplicated notifications issue. #530

Closed matrosovDev closed 8 years ago

matrosovDev commented 8 years ago

I faced with duplicated notifications issues.

  1. For making subscription I invoke this code:
 let subscription = QBMSubscription()
    subscription.notificationChannel = QBMNotificationChannelAPNS
    subscription.devicePlatform = "iOS"
    subscription.deviceToken = deviceToken
    subscription.deviceUDID = UIDevice.currentDevice().identifierForVendor!.UUIDString

    QBRequest.createSubscription(subscription, successBlock: { (response: QBResponse!, objects :[QBMSubscription]?) in
      if let createdSubscription = objects?.first {
        self.currentSubscriptionID = createdSubscription.ID
      } else {
        print("failure in Subscription to apns for QB with failureResponse: \(response) and objects:\(objects)")
      }
      }) {(failureResponse: QBResponse) in
        print("failure in Subscription to apns for QB: : \(failureResponse)")
    }

So when I tested it all was subscribed with success but not on all devices but on iPhone 6 plus 9 iOS 9.2.1 (and other 9+).

  1. Also for unsubscribe I use this code
let deviceUDIDStr  = UIDevice.currentDevice().identifierForVendor!.UUIDString

    QBRequest.unregisterSubscriptionForUniqueDeviceIdentifier(deviceUDIDStr, successBlock: { (response: QBResponse) in
      print("unregisterSubscriptionToNotification successBlock:\(response)")
      completion()
    }) { (error: QBError?) in
      print("unregisterSubscriptionToNotification error:\(error)")
      completion()
    }

but I got error:

errors =     (
        "Device UDID is different"
    );

Thanks for help

matrosovDev commented 8 years ago

Also I know about Apple bug with duplicated push notification so I fixed it on my side. Invocation twice this line application.registerForRemoteNotifications() leads duplicated issue.

Mentioned here as well: http://stackoverflow.com/questions/32840916/receiving-duplicate-push-notification-ios9

but in any case it does not resolve issue I've created.

ghost commented 8 years ago

Hi @matrosovDev, Please check if UDID is the same for subscribe and unsubscribe

matrosovDev commented 8 years ago

Hey Andrey, by the way the UDID is the second issue, the main issue duplicated notifications. As I've described above when I create subscription I use this:

subscription.deviceUDID = UIDevice.currentDevice().identifierForVendor!.UUIDString

and when I unsubscribe I use:

let deviceUDIDStr = UIDevice.currentDevice().identifierForVendor!.UUIDString

As you see it's the same UDID received from SDK.

But in any case most important issue that I have duplicated notifications that I can see seems only on iPhone 6 plus.

Thanks

ghost commented 8 years ago

@matrosovDev I've tested subscribing and unsubscribing on device iPhone 6 iOS 9.3.2 on your server and I haven't caught this error.

matrosovDev commented 8 years ago

let's skip subscribe and unsubscribe issue, the main issue for now it's duplicated issues, though that may connected to subscribe/unsubscribe issue.

ghost commented 8 years ago

You said and I figured out that double notifications is Apple bug, so how can we fix it?

matrosovDev commented 8 years ago

I resolved apple bug, because we don't need to use device token twice as I shared with link above, though the issue with duplicated push notification is still there.

I fixed Apple bug, but not an issue.

Raikerian commented 8 years ago

Hi @matrosovDev

In order to understand this issue we require a full logs from app start till the error occurs. Those logs should contain successful subscribe and unsuccessful unsubscribe requests.

Raikerian commented 8 years ago

@matrosovDev do you have any updates? Were you able to fix this?

nikhilchaurasia commented 7 years ago

I am also getting same issue. The control is coming back two times in error block.