{"_id":"59e70b9fe027ae002e7d2f23","category":{"_id":"59e70b9ee027ae002e7d2ed4","version":"59e70b9ee027ae002e7d2ed2","project":"5496d393f52a630b00519cdd","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-01T11:28:38.565Z","from_sync":false,"order":1,"slug":"getting-started-ios","title":"iOS Reference"},"parentDoc":null,"project":"5496d393f52a630b00519cdd","user":"5496d353f52a630b00519cdc","version":{"_id":"59e70b9ee027ae002e7d2ed2","project":"5496d393f52a630b00519cdd","__v":2,"createdAt":"2017-10-18T08:06:54.462Z","releaseDate":"2017-10-18T08:06:54.462Z","categories":["59e70b9ee027ae002e7d2ed3","59e70b9ee027ae002e7d2ed4","59e70b9ee027ae002e7d2ed5","59e70b9ee027ae002e7d2ed6","59e70b9ee027ae002e7d2ed7","59e70b9ee027ae002e7d2ed8","59e70b9ee027ae002e7d2ed9","59e70b9ee027ae002e7d2eda","59e70b9ee027ae002e7d2edb","59e70b9ee027ae002e7d2edc","59e70b9ee027ae002e7d2edd","59e70b9ee027ae002e7d2ede","59e70b9ee027ae002e7d2edf","5b8661ccdd19310003a3fa0b"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"2.0.10","version":"2.0.10"},"githubsync":"","__v":0,"metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-01T12:08:38.851Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Activating Geofencing Triggers\"\n}\n[/block]\nAfter activating Placer SDK, set the \"setGeofencesSupport\" to \"YES\". \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Placer setGeofencesSupport:YES];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Register your Geofence handling function with NSNotificationCenter\"\n}\n[/block]\nSet your handling function to receive notifications:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[[NSNotificationCenter defaultCenter] addObserver:self\\n                                      selector::::at:::selector(onGeofenceBump:)          \\n                                      name:PLNotificationGeofenceBump\\n                                      object:nil];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n**All done.** Geofence triggers will be sent to your handler function.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example\"\n}\n[/block]\nThe following example shows how to handle a geofence event:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"    //YOUR GEOFENCE NOTIFICATIONS HANDLER\\n- (void)onGeofenceBump:(NSNotification *)notification{\\n\\n    if (notification==nil){\\n        return;\\n    }\\n       \\n    PLTriggerEvent *triggerEvent = [notification.userInfo objectForKey:PLUserInfoGeofence];\\n    PLGeofence *geofence = triggerEvent.geofence;\\n\\n    if(triggerEvent==nil || geofence == nil){\\n        return;\\n    }\\n\\n    // Mandatory fields\\n    NSLog(@\\\"Geofence timestamp: %@\\\", triggerEvent.timestamp);\\n    NSLog(@\\\"Geofence type: %ld\\\", (long)triggerEvent.type);\\n    NSLog(@\\\"Geofence name: %@\\\", geofence.name);\\n\\n    // Optional fields, provided by customer\\n    NSLog(@\\\"Geofence id: %@\\\", geofence.identifier );\\n    NSDictionary<NSString *, NSString *> *customData = geofence.customData;\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","excerpt":"Geofencing allows you to receive triggers in the client.\nTo add geofence POIs please use the designated menu in [our dashboard](https://dashboard.placer.io/#/geofence-custom-pois)","slug":"geofencing","type":"basic","title":"Geofencing"}

Geofencing

Geofencing allows you to receive triggers in the client. To add geofence POIs please use the designated menu in [our dashboard](https://dashboard.placer.io/#/geofence-custom-pois)

[block:api-header] { "type": "basic", "title": "Activating Geofencing Triggers" } [/block] After activating Placer SDK, set the "setGeofencesSupport" to "YES". [block:code] { "codes": [ { "code": "[Placer setGeofencesSupport:YES];", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Register your Geofence handling function with NSNotificationCenter" } [/block] Set your handling function to receive notifications: [block:code] { "codes": [ { "code": "[[NSNotificationCenter defaultCenter] addObserver:self\n selector:@selector(onGeofenceBump:) \n name:PLNotificationGeofenceBump\n object:nil];", "language": "objectivec" } ] } [/block] **All done.** Geofence triggers will be sent to your handler function. [block:api-header] { "type": "basic", "title": "Example" } [/block] The following example shows how to handle a geofence event: [block:code] { "codes": [ { "code": " //YOUR GEOFENCE NOTIFICATIONS HANDLER\n- (void)onGeofenceBump:(NSNotification *)notification{\n\n if (notification==nil){\n return;\n }\n \n PLTriggerEvent *triggerEvent = [notification.userInfo objectForKey:PLUserInfoGeofence];\n PLGeofence *geofence = triggerEvent.geofence;\n\n if(triggerEvent==nil || geofence == nil){\n return;\n }\n\n // Mandatory fields\n NSLog(@\"Geofence timestamp: %@\", triggerEvent.timestamp);\n NSLog(@\"Geofence type: %ld\", (long)triggerEvent.type);\n NSLog(@\"Geofence name: %@\", geofence.name);\n\n // Optional fields, provided by customer\n NSLog(@\"Geofence id: %@\", geofence.identifier );\n NSDictionary<NSString *, NSString *> *customData = geofence.customData;\n}", "language": "objectivec" } ] } [/block]