Crash in BMSPushClient.swift:726
Closed this issue · 4 comments
meyumeapps commented
We've also picked this one up as well.
Any help much appreciated.
Thanks
Scott
Using BMSAnalyticsAPI (2.2.0)
Using BMSCore (2.3.1)
Using BMSPush (3.1.1)
meyumeapps commented
We think the problem is because we are calling:
- get tags
- unsubscribe
- subscribe
and they are happening async
So, we just put a dispatch queue around and made them serialised.
We'll see how it goes.
Here's the code:
`//Initialize client Push SDK for Swift
let push = BMSPushClient.sharedInstance
push.initializeWithAppGUID(appGUID: weatherGodsBluemixAppGUID, clientSecret: weatherGodsBluemixClientSecret)
log.info("Subscribing with tag: \(tag)")
let tags = [tag]
var orphanedTags = [String]()
let group = DispatchGroup()
group.enter()
BMSPushClient.sharedInstance.retrieveSubscriptionsWithCompletionHandler { (availableTagsArray, statusCode, error) in
if error.isEmpty {
log.info( "Response during retrieve subscriptions : \(String(describing: availableTagsArray?.description))")
log.info( "status code during retrieve subscriptions : \(String(describing: statusCode))")
if let tagsToCheck = availableTagsArray?.copy() as? [String] {
for tagToCheck in tagsToCheck {
if tagToCheck.hasPrefix("weather-gods-heartbeat") && tagToCheck != tag {
log.debug("Will unsubscribe from \(tagToCheck)")
orphanedTags.append(tagToCheck)
}
}
if orphanedTags.count > 0 {
BMSPushClient.sharedInstance.unsubscribeFromTags(tagsArray: orphanedTags as NSArray, completionHandler: { (response, statusCode, error) in
if error.isEmpty {
log.info( "Response during unsubscribing from tags : \(String(describing: response?.description))")
log.info( "status code during unsubscribing from tags : \(String(describing: statusCode))")
} else {
log.error( "Error during unsubscribing from tags \(error) ")
log.error( "Error during unsubscribing from tags \n - status code: \(String(describing: statusCode)) \n Error :\(error) \n")
}
group.leave()
})
} else {
group.leave()
}
}
} else {
log.error( "Error during retrieve subscriptions \(error) ")
log.error( "Error during retrieve subscriptions \n - status code: \(String(describing: statusCode)) \n Error :\(error) \n")
group.leave()
}
}
group.wait()
BMSPushClient.sharedInstance.subscribeToTags(tagsArray: tags as NSArray) { (response, statusCode, error) in
if error.isEmpty {
log.info( "Response during Subscribing to tags : \(String(describing: response?.description))")
log.info( "status code during Subscribing tags : \(String(describing: statusCode))")
} else {
log.error( "Error during Subscribing tags \(error) ")
log.error( "Error during Subscribing tags \n - status code: \(String(describing: statusCode)) \n Error :\(error) \n")
}
}
`
AnanthaKrish commented
@meyumeapps Hi, Fix will be available in next release :)
meyumeapps commented
Thanks, how soon?
Kind regards
Scott
Check out my app Weather Gods 🙏
https://itunes.apple.com/us/app/weather-gods/id1041512978?mt=8
… On 5 Apr 2017, at 10:17, Anantha Krishnan K G ***@***.***> wrote:
@meyumeapps <https://github.com/meyumeapps> Hi, Fix will be available in next release :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#42 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AEDkdMPSn9dwuJLge12R4HY46Vc9JHbYks5rs1wOgaJpZM4MrNYZ>.
AnanthaKrish commented
Issue is solved , hence closing the defect