0

I was following Google's documentation for using NearbyMessages API. I'm using Swift3. I have the following code to set up the app to publish to nearby.

let messageManager = GNSMessageManager(apiKey: "someky")
var publication: GNSPublication?
let message = GNSMessage(content:"name".data(using: .utf8))
if let messageManager = messageManager, let message = message {
   publication = messageManager.publication(with:message)
}

I ran the app on the simulator. Then the app crashes in the 5th line (The line in the if-let block). Here's part of the stack trace:

(
0   CoreFoundation                      0x000000011302334b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x000000011271e21e objc_exception_throw + 48
2   CoreFoundation                      0x000000011308c265 +[NSException raise:format:] + 197
3   Foundation                          0x0000000112229fdc -[NSConcreteMutableAttributedString initWithString:] + 129
4   ProjectLibs                         0x000000011879b55a gns_localizedAllowAppToConnectAttributedString + 415
5   ProjectLibs                         0x000000011879b8b9 gns_localizedAllowAppToConnectString + 75
6   ProjectLibs                         0x000000011879ae9f gcp_verifyDealloc + 24324
)

Since the messageManager and the message are both protected by the if-let block, I cannot find where is the nil exception coming from. Does anyone know why would there be a nil value in this block of code?

Thank you very much!

1 Answers1

0

Does it work on a device? There is a bug in Nearby Messages 1.1.0 that causes a nil pointer exception on the simulator when you use BLE as a discovery medium.

Apologies! We'll get the bug fixed in the next release.

Dan Webb
  • 348
  • 1
  • 7