kontaktio / kontakt-ios-sdk

This SDK makes it easy for you to configure, monitor, and securely update Kontakt.io Beacons through our Kontakt.io API.
http://developer.kontakt.io
Other
48 stars 9 forks source link

Can't monitor Eddystone regions with only a namespaceId #76

Closed nashfive closed 5 years ago

nashfive commented 5 years ago

Hi @stoprocent, I want to be able to monitor (scan) Eddystone regions by providing only the regions' namespaceId so I try to add regions like so:

NSMutableArray<KTKEddystoneRegion *> * namespaces = [NSMutableArray array];
NSArray * args = (NSArray *)call.arguments[@"namespaces"] ?: @[];
for (NSDictionary * namespaceDict in args) {
            NSString * namespaceId = namespaceDict[@"namespaceId"];
            NSString * instanceId = namespaceDict[@"instanceId"];
            KTKEddystoneRegion * region;
            if (namespaceId != nil && instanceId != nil) {
                region = [[KTKEddystoneRegion alloc] initWithNamespaceID:namespaceId instanceID:instanceId];
            }
            else if (namespaceId != nil) {
                region = [[KTKEddystoneRegion alloc] initWithNamespaceID:namespaceId];
            }
            else {
                // Eddystone region can't have only an instanceId
                continue;
            }
            [namespaces addObject:region];
        }

The problem is that the scan doesn't produce anything.

This works perfectly with the Android SDK. Can you elaborate why?

nashfive commented 5 years ago

Oh sorry, I think it was due to an error in my code: namespaceDict[@"instanceId"] was giving me a NSNull object instead of nil.