iOS Push notification crash
If my app is in inactive state and if a push notification comes , my app crashes while launching.
This set of code is present in didFinishLaunchingWithOptions :
[[ServicesManager sharedInstance] setAppID:kAppID secretKey:kSecretKey];
[[ServicesManager sharedInstance].rtcService requestMicrophoneAccess];
[[ServicesManager sharedInstance].rtcService startCallKitWithIncomingSoundName:@"incoming-call.mp3" iconTemplate:@"Icon-40.png" appName:[self applicationName]];
[[ServicesManager sharedInstance].rtcService setAppSoundOutgoingCall:@"outgoing-rings.mp3"];
[[ServicesManager sharedInstance].rtcService setAppSoundHangup:@"hangup.wav"];
If i remove this , notifications work fine.
How to handle that ? Any suggestions?
-
Hello Prakash ,
Hers's the solution i came up with ,I just put the code on main thread..
dispatch_async(dispatch_get_main_queue(), ^{
[[ServicesManager sharedInstance] setAppID:kAppID secretKey:kSecretKey];
[[ServicesManager sharedInstance].rtcService requestMicrophoneAccess];
[[ServicesManager sharedInstance].rtcService startCallKitWithIncomingSoundName:@"incoming-call.mp3" iconTemplate:@"Icon-40.png" appName:[self applicationName]];
[[ServicesManager sharedInstance].rtcService setAppSoundOutgoingCall:@"outgoing-rings.mp3"];
[[ServicesManager sharedInstance].rtcService setAppSoundHangup:@"hangup.wav"];
});
It Worked forme , Do let me know if it works for you ..... :)
-
Hi Apurva,
Thanks for your response.
I tried above the code. i am getting same crash. check below link for my issue detail.
https://support.openrainbow.com/hc/en-us/community/posts/360007050299-Notification-click-and-open-the-app-get-crashed-in-iOS -
Hi,
I am calling this method from didFinishlaunching.func configRainbow() {
DispatchQueue.main.async {
ServicesManager.sharedInstance()?.setAppID(kID, secretKey:kSecretKey)
ServicesManager.sharedInstance()?.rtcService.requestMicrophoneAccess()
ServicesManager.sharedInstance()?.rtcService.startCallKit(withIncomingSoundName: "incoming-call.mp3", iconTemplate: "", appName: "MYAPP")
ServicesManager.sharedInstance()?.rtcService.appSoundOutgoingCall = "outgoing_ringing.mp3"
ServicesManager.sharedInstance()?.rtcService.appSoundHangup = "hangup.wav"
self.registerForPushNotifications()
}
}
-
Try putting self.registerForPushNotifications() outside the thread....
func configRainbow() {
DispatchQueue.main.async {
ServicesManager.sharedInstance()?.setAppID(kID, secretKey:kSecretKey)
ServicesManager.sharedInstance()?.rtcService.requestMicrophoneAccess()
ServicesManager.sharedInstance()?.rtcService.startCallKit(withIncomingSoundName: "incoming-call.mp3", iconTemplate: "", appName: "MYAPP")
ServicesManager.sharedInstance()?.rtcService.appSoundOutgoingCall = "outgoing_ringing.mp3"
ServicesManager.sharedInstance()?.rtcService.appSoundHangup = "hangup.wav"
}
}
self.registerForPushNotifications()
Please sign in to leave a comment.
Comments
7 comments