2014-06-27 98 views
0

林熟悉解析推送通知,但在規劃一個應用程序,我有一個想法發送推送通知,一旦用戶在某個位置(公園,博物館等)解析推送通知與位置IOS

這可能嗎?

+0

我的唯一方法可以認爲這樣做與Parse是讓客戶端將其位置報告給Parse。那麼你需要一些雲代碼來完成剩下的工作。我沒有知道專門爲此場景內置的Parse。 –

回答

0

這可以很容易地完成,無需解析。在應用程序委託

// 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]; 


} 

}

記住在你的info.plist中添加添加該代碼

「應用程序註冊了位置更新」