Netmera Developer Guide
Netmera Docs
  • Netmera Developer Guide
  • Platforms
    • iOS
      • New iOS (Swift)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Widget and In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Advertising ID
        • Changelog
      • Former iOS (Objective-C)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Push Payload Receivers
          • Widget and In-App Messages
          • Customizing In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
          • Custom Web View Presentation
          • Push Icon
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Data Transfer
        • Advertising ID
        • SSL Pinning
        • Changelog
    • Android
      • SDK Integration
        • Huawei Integration
        • Huawei Message Receipt
        • Custom FCM and HMS Implementations
        • Android Integration FAQs
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
        • Custom Web View Presentation
        • Push Icon
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
        • Background Location Permission
      • User & Attributes
      • Data Transfer
      • Advertising ID
      • App Tracking
      • SSL Pinning
      • Changelog
    • Web
      • SDK Setup
        • Self-Hosted SDK Setup
      • Mobile Web Push for iOS
      • Deep Linking
        • Custom Deep Links
      • Events
      • User & Attributes
    • React Native
      • SDK Integration
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • Changelog
    • Flutter
      • SDK Integration
        • Custom FCM and HMS Implementations
      • Push Notifications
        • Push Notification Permissions
        • Widget and In-App Messages
        • Flutter iOS Media Push
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • SSL Pinning
      • Changelog
    • Cordova
      • SDK Integration
      • Push Notifications
      • Sound & Vibration
      • Push Inbox
      • Events
      • User & Attributes
    • Unity
      • SDK Integration
      • Sound & Vibration
      • Events
      • User & Attributes
      • Changelog
  • Integrated Modules
    • Optimove
    • Adjust
    • Mixpanel
    • IYS Integration
    • VIA Integration
      • Short URL Consent Requests
      • OTP Consent Requests
        • OTP Confirmation Completion
      • VIA Email Rejection Link Generation
      • ETK Rejection via SMS
  • API Documentation
    • REST API
      • Setup
      • Notifications
      • Events
      • User & Device Management
      • Inbox Feature
      • GDPR
      • Error Responses
  • FAQs
    • Push Notifications FAQs
Powered by GitBook
On this page
  • Step 1: Enable Location History
  • Step 2: iOS Integration
  • 1. Configure Location Permissions
  • Step 3: Android Integration
  • 1. Add Required Permissions
  • 2. Configure Location Hardware Requirements (Optional)
  • Step 4: Location Authorization
  • Step 5: Geofence Region Limits (Optional)
  • Troubleshooting

Was this helpful?

  1. Platforms
  2. Flutter

Geofence & Location

By default, Netmera SDK does not collect location information from the device. To use features like geofence messaging and location-based user targeting, you must enable location tracking.

Step 1: Enable Location History

To use location-based targeting, enable Location History in the Netmera web panel: Developers > App Info > App Config > Location History Enabled

Step 2: iOS Integration

1. Configure Location Permissions

Add the necessary authorization keys to your Info.plist file:

  1. For Geofence Messaging (iOS 10 and earlier)

  • Set NSLocationAlwaysUsageDescription with a description explaining why the app uses region monitoring.

  • This allows the SDK to monitor region entry/exit actions for geofence regions configured in the Netmera Dashboard.

  1. For Geofence Messaging (iOS 11 and later)

  • Set NSLocationAlwaysAndWhenInUseUsageDescription with a description explaining why the app uses region monitoring.

  • This allows the SDK to monitor region entry/exit actions for geofence regions configured in the Netmera Dashboard.

  1. For Occasional Location Updates

  • Set NSLocationWhenInUseUsageDescription with a description.

  • This sends the most recent location once per session.

Step 3: Android Integration

On Android 10 and later, geofence push notifications require background location access. However, Android does not allow apps to request this permission directly in the app. Instead, users must manually enable "Allow all the time" in the system settings.

Best Practice: Before redirecting users to settings, display an explanatory message about why location access is needed. You can use Netmera widgets to communicate this effectively. You may see the next page Background Location Permission on how to create these widgets to ask for location permissions.

1. Add Required Permissions

In your AndroidManifest.xml file, add the following permissions:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

2. Configure Location Hardware Requirements (Optional)

If your app requires location-based services but should still be visible on devices without GPS hardware, add the following declarations in AndroidManifest.xml:

<uses-feature
      android:name="android.hardware.location"
      android:required="false" />
<uses-feature
      android:name="android.hardware.location.gps"
      android:required="false" />

Step 4: Location Authorization

For Android 6.0 (API Level 23) and later, location permission must be requested while the app is running. Netmera provides a built-in permission request flow:

Netmera.requestPermissionsForLocation();

Calling these methods immediately prompts the location permission dialog. Make sure to inform users beforehand about how your application will use their location.

Step 5: Geofence Region Limits (Optional)

To set the maximum number of active geofence regions, use:

Netmera.setNetmeraMaxActiveRegions(10);

For iOS: If the value is set greater than 20 or less than 0, it will be automatically reset to 20.

For Android: If you set a value greater than 95 or less than 0, it will be reset to the default (95).

Troubleshooting

Geofence Update Events: Common Causes and Solutions

The Netmera SDK triggers the Geofence Update event when there is a change in the geofence area, prompted by the operating system. However, if the operating system does not trigger this event, you may not see the geofence update events. This can occur due to various reasons such as operating system limitations or device settings.

Possible Reasons for Not Seeing Geofence Update Events
  1. Operating System Does Not Trigger the Event: Geofence events are triggered by the operating system. However, due to power-saving policies or system restrictions, this trigger may not occur.

  2. Background Process Restrictions

    • Some Android devices, particularly those with low memory, may restrict background processes.

    • If the app has been "Force Stopped," geofence events will not be triggered.

  3. Battery Optimization Mode

    • If the device is in battery optimization mode, geofence services may operate with limited functionality.

    • For example, background location services may be disabled.

  4. Device and Operating System Manufacturer Restrictions

    • Some device manufacturers (e.g., Xiaomi, Oppo, Huawei) may restrict geofence events through their own power-saving mechanisms.

  5. Location Services Disabled

    • If the user has disabled location services on the device, geofence events cannot be triggered.

  6. Missing App Permissions

    • If Location Permission is not granted, or if the permission level is restricted (e.g., "Only While Using the App"), geofence events will not be received.

Suggestions for Optimizing Geofence Events

1. Prompt Users to Enable Permissions

You can show an informative message to remind users to keep location services and permissions enabled.

Example message:

"If your location services are off, you may not see geofence events. Go to Settings > Location > [App Name] > Allow Always to update your permissions."

You can also inform users through Netmera Widgets.

2. Check Battery Optimization Settings

Due to energy-saving modes, background processes may be restricted. Direct users to add your app to the battery optimization exceptions list.

Steps:

  1. Go to Settings > Apps > Find [App Name].

  2. Enter Battery settings.

  3. Enable Battery Optimization.

  4. Select Don’t Optimize or No Restrictions.

3. Disable Background Process Restrictions

Some device manufacturers may automatically restrict background app processes. To remove these restrictions, follow the steps according to the device type:

Xiaomi:

  1. Go to Settings > Battery & Performance > App Battery Saver.

  2. Select the app and choose No Restrictions.

Huawei:

  1. Go to Settings > Battery > App Launch Management.

  2. Disable Automatic Management for the app.

  3. Enable all permissions under Manual Management.

Oppo and Vivo:

  1. Go to Settings > Power Management > Background Restrictions.

  2. Ensure your app is not listed here.

4. Increase Location Accuracy

To improve geofence performance, check and adjust the device’s location accuracy settings.

Steps:

  1. Go to Settings > Location > Advanced.

  2. Enable Google Location Accuracy or High Accuracy Mode.

Ensure the above settings are properly configured on users' devices to enable geofence update events to be received correctly. Adding informative messages to guide users in optimizing these settings will help enhance geofence functionality.

PreviousEventsNextUser & Attributes

Last updated 1 month ago

Was this helpful?