1

I am pretty new to iOS programming and still learning a lot. I was hoping to make an alert view pop up automatically on a certain screen. Basically I am using the new qualquamm Gimbal beacons for an app. This code triggers a log when a beacon is first found:

// FYXVisitDelegate protocol
- (void)didArrive:(FYXVisit *)visit;
{
    // this will be invoked when an authorized transmitter is sighted for the first time
    NSLog(@"I arrived at a Gimbal Beacon!!! %@", visit.transmitter.name);


}

What I would like to do is have this trigger a pop up or alert when first found saying what the log says just for testing. I would like to brand the alert but heard that is not possible in iOS 7 anymore so if there are any suggestions for a pop up as well I would love to hear.

This is what I had with no luck (the log still is trigged though):

- (void)didArrive:(FYXVisit *)visit;
{
    // this will be invoked when an authorized transmitter is sighted for the first time
    NSLog(@"I arrived at a Gimbal Beacon!!! %@", visit.transmitter.name);

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" message:@"%@" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:@"View", visit.transmitter.name, nil];

    [alert show];
}
self.name
  • 2,341
  • 2
  • 17
  • 18
Packy
  • 3,405
  • 9
  • 50
  • 87

1 Answers1

0

The problem is probably your message string assignment, you're using a format string @"%@" but you're missing the call to stringWithFormat:

Old code: (check out the message parameter)

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" message:@"%@" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:@"View", visit.transmitter.name, nil];

New code: (notice the [NSString stringWithFormat] call)

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" message:[NSString stringWithFormat:@"%@",  visit.transmitter.name] delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:@"View",  visit.transmitter.name, nil];

The old code also assigned an alertView button to be named after the transmitter's name. I kept this in the new code, but remove the "visit.transmitter.name" from the otherButtonTitles: parameter if you don't want it.

Also, if you're looking for updates while a visit is in progress, use this FYXVisitManager delegate method:

  • (void)receivedSighting:(FYXVisit *)visit updateTime:(NSDate *)updateTime RSSI:(NSNumber *)RSSI;
self.name
  • 2,341
  • 2
  • 17
  • 18