Documentation

Modify AndroidManifest


Declare permissions, services, and receivers in your app's AndroidManifest.xml file.

Declare Permissions


Our SDK requires that you declare the following permissions:

  1. android.permission.INTERNET - so that devices will be able to connect to our service
  2. android.permission.WAKE_LOCK - so that devices won't disconnect their Wi-Fi connection during sleep
  3. android.permission.ACCESS_NETWORK_STATE - so that the SDK will be able to check for an active Internet connection
  4. android.permission.RECEIVE_BOOT_COMPLETED - so that devices will reconnect to our network after they finish booting up
  5. android.permission.WRITE_EXTERNAL_STORAGE - so that the SDK will be able to persist device tokens in the external storage

Add the following lines to your AndroidManifest.xml, inside the <manifest> tag:

<!-- Pushy Permissions -->
                                    
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!-- End Pushy Permissions -->

You should manually omit any permission declarations that your app already asks for.

Note: android.permission.WRITE_EXTERNAL_STORAGE is optional - it is necessary only for persisting device tokens in the external storage for when your app is reinstalled, so we don't charge you twice for the same device. If this permission is not declared, the SDK will persist device tokens only within your app's SharedPreferences, which are cleared when your app is uninstalled.

Add Services & Receivers


Our SDK requires that you add the following internal services and receivers to your AndroidManifest.xml:

  1. me.pushy.sdk.receivers.PushyBootReceiver - so that devices will reconnect to our network when they boot up
  2. me.pushy.sdk.receivers.PushyUpdateReceiver - so that devices will reconnect to our network when your app gets updated
  3. me.pushy.sdk.services.PushySocketService - so that devices will be able to establish an idle background connection with our service
  4. me.pushy.sdk.services.PushyJobService - so that devices running Android Oreo and up will be able to establish an idle background connection with our service (Pushy SDK 1.0.35 and up)

Add the following lines to your AndroidManifest.xml, inside the <application> tag:

<!-- Pushy Declarations -->

<!-- Pushy Notification Receiver -->
<!-- Incoming push notifications will invoke the following BroadcastReceiver -->
<receiver android:name=".PushReceiver" android:exported="false">
    <intent-filter>
        <!-- Do not modify this -->
        <action android:name="pushy.me" />
    </intent-filter>
</receiver>

<!-- Pushy Update Receiver -->
<!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
<receiver android:name="me.pushy.sdk.receivers.PushyUpdateReceiver" android:exported="false">
    <intent-filter>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>

<!-- Pushy Boot Receiver -->
<!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
<receiver android:name="me.pushy.sdk.receivers.PushyBootReceiver" android:exported="false">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>

<!-- Pushy Socket Service -->
<!-- Do not modify - internal service -->
<service android:name="me.pushy.sdk.services.PushySocketService"/>

<!-- Pushy Job Service (added in Pushy SDK 1.0.35) -->
<!-- Do not modify - internal service -->
<service android:name="me.pushy.sdk.services.PushyJobService"
    android:permission="android.permission.BIND_JOB_SERVICE"
    android:exported="true" />

<!-- End Pushy Declarations -->

Note: Ignore the .PushReceiver reference error. We'll take care of that in the next step.