infobip / mobile-messaging-sdk-ios

Mobile Messaging SDK for iOS
Apache License 2.0
55 stars 19 forks source link

didRegisterForRemoteNotificationsWithDeviceToken method not called #9

Closed akshardarji closed 5 years ago

akshardarji commented 5 years ago

Please fill out the following form to help us to resolve you issue faster.

[MobileMessaging] ‼️ [Checking versions] An error occurred while trying to validate library version: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9800, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x1d4240bd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9800, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9800}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://mobile.infobip.com/mobile/3/version?platformType=APNS, NSErrorFailingURLStringKey=https://mobile.infobip.com/mobile/3/version?platformType=APNS, _kCFStreamErrorDomainKey=3}

While doing following steps got above mentioned error: MobileMessaging.withApplicationCode("APPCODE", notificationType: UserNotificationType(options: [.alert, .sound, .badge]))?.start({ })

Occurred for following call:

mmContext.remoteApiProvider.fetchRecentLibraryVersion(applicationCode: mmContext.applicationCode, pushRegistrationId: mmContext.currentUser.pushRegistrationId) 
{
         self.handleResult(result: $0)
         completion?()
}

func handleResult(result: LibraryVersionResult) {
        if let response = result.value {
            if shouldShowNewVersionWarning(onlineVersion: response.libraryVersion, localVersion: mobileMessagingVersion) {
                showNewVersionWarning(localVersion: mobileMessagingVersion, response: response)
            } else {
                handleUpToDateCase()
            }
        } else {
            MMLogError("[Checking versions] An error occurred while trying to validate library version: \(result.error.orNil)")
        }
    }

error printing the log from :

MMLogError("[Checking versions] An error occurred while trying to validate library version: (result.error.orNil)")

We are blocked here, could you please help me out.

Thanks.

kas-kad commented 5 years ago

We are blocked here, could you please help me out.

Hello, please clarify how do you mean "blocked"? This error does not affect SDK functionality. In details, it just fails to check new SDK version available on github. Probably some authentication certificate issue on our side. You can ignore the error until we fix it.

akshardarji commented 5 years ago

For iOS 11.0.2, while doing following code:

MobileMessaging.withApplicationCode("APPCODE", notificationType: UserNotificationType(options: [.alert, .sound, .badge]))?.start({ })

didn't called didRegisterForRemoteNotificationsWithDeviceToken method so due to that we can't able to get any push notifications. Please provide me solutions for the same.

(Note: For other version of iOS working fine.)

kas-kad commented 5 years ago

Hello, make sure you've read this article. Let me know if any questions arise.

kas-kad commented 5 years ago

What are the other iOS versions you mentioned?

akshardarji commented 5 years ago

Hello, make sure you've read this article. Let me know if any questions arise.

I have read that and working fine for other iOS version but not worked only on iOS 11.0.2. Yes I have setup with sandbox env.

What are the other iOS versions you mentioned?

Working Fine on iOS version : (10.x.x, 11.1.x < 11.4.x , 12.x)

Not Working on iOS version : (11.0.x)

kas-kad commented 5 years ago

Did you try to uninstall-install the application?

akshardarji commented 5 years ago

Yeah Obviously. I have tried many time and tried after rebooting device too.

kas-kad commented 5 years ago

This looks weird and for me it is impossible to say what may be wrong. The fastest solution would be to check if Push works against production APNS environment (you need to to issue a production APNS certificate, create a Production Push Application on our Portal, get a new Application Code, provision your iOS application build with Ad-Hoc Provisioning Profile.

kas-kad commented 5 years ago

I made a quick search and found this topic, related to Push issues on early iOS 11's

kas-kad commented 5 years ago

@akshardarji have you found a solution?

akshardarji commented 5 years ago

Yeah found it. There had applied proxy so that whenever tried to connect APNS, it's been failed that request and due to that never came to didRegisterForRemoteNotificationsWithDeviceToken method.

Thanks for your instant support. 👍

fparkar commented 4 years ago

@akshardarji : You mentioned "There had applied proxy".. Could you please illustrate more on this...

I am also facing issue where didRegisterForRemoteNotificationsWithDeviceToken is not called in iOS 13 (iOS 12 & lower working fine).

akshardarji commented 4 years ago

@fparkar Yes, It's an iOS issue.

You can find the iOS - release note.

Release iOS-13.3.1 - Resolves an issue where push notifications could fail to be delivered over Wi-Fi

https://support.apple.com/en-in/HT210393#1331

kas-kad commented 4 years ago

@apphardtask did you try to that under cellular network?

fparkar commented 4 years ago

@kas-kad : Cellular works fine. Problem in WIFI only.

But to work with WIFI, I have to use NSTimer & keep on calling register token every 5 seconds.

fparkar commented 4 years ago

@akshardarji : However I am facing this in iOS 13.4.1 also.

What I did now is add a timer & call registration for push every 5 seconds and on success stop the timer.

This way, I am getting token however token is wrong. I need to check further. Will update once I get something.

Note : I am using Objective C code and not swift as this is old project.

kas-kad commented 4 years ago

Check with your network administrator https://support.apple.com/en-us/HT203609

kas-kad commented 4 years ago

@fparkar also, try one more thing: disable your timer, you don't need it for the experiment.

  1. Start the app
  2. register for APNs token
  3. if none received, stop the app, repeat from pt.1, this time you should receive the token.
fparkar commented 4 years ago

@kas-kad : "if none received, stop the app".. how? manually kill app you meant?

kas-kad commented 4 years ago

yes

fparkar commented 4 years ago

@kas-kad : I can't do that 1 by 1 to all my live users. This problem is coming on live also.

So NSTimer is the only solution I think. But I need to work on it.

kas-kad commented 4 years ago

@fparkar what I've proposed is just an experiment, not a solution for production release.

kas-kad commented 4 years ago

@fparkar let me know about the results

kas-kad commented 4 years ago

@fparkar after you've done with the experiment, try to build your app for distribution (using Distribution Provisioning profile: either Ad-Hoc or AppStore). Does the registration perform well in such build config?

fparkar commented 4 years ago

@kas-kad : No, problem in live. So when I check with development mode, I found because token is not registered and hence push is not getting.

So I put logs and found that for iOS token is null and when I debug more I found push notification is not getting registered and hence token is not sent to server and hence push is not sent to the device.

kas-kad commented 4 years ago

@fparkar let me summarize. You don't get registration token (didRegisterForRemoteNotificationsWithDeviceToken not called) while under Wi-Fi and only under Wi-Fi, however under Cellular you have no issues. Also, you are able to workaround the issue by retrying the registration with timer. The issue is present for both Release and Debug builds (Distribution and Development builds). Is that correct?

fparkar commented 4 years ago

@kas-kad : Yes.

Note : But one of my friend have mobile network. On live app he is also not getting push notification. So saying notification not working on WIFI only is not 100% confirmed for me.