IOS Location Transfer Notifications

I am familiar with Parse Push notifications, but when planning the application I had an idea to send a push notification after the user is in a certain place (park, museum, etc.).

Is it possible?

0
source share
1 answer

This can be done easily and without parsing. Add this code to your application delegate



// START WITH [self.locationManager startUpdatingLocation];

pragma mark - CLLocationManagerDelegate

/* * locationManager:didUpdateToLocation:fromLocation: * */ - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

if (UIApplication.sharedApplication.applicationState == UIApplicationStateActive)
{
    // ACTIVE APP, pin in a map

}
else
{
    NSLog(@"App is backgrounded. New location is %@", newLocation);

    // LOCAL PUSH IF NEAR. 


   UILocalNotification *notification = [[UILocalNotification alloc] init];
                notification.alertBody = @"You are near";
                [[UIApplication sharedApplication] presentLocalNotificationNow:notification];


}

}

code>

Do not forget to add to your info.plist

Location Register Application Registers

0
source

All Articles