Modify AndroidManifest


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

Declare Permissions


Our SDK requires 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 after they finish booting up
  5. android.permission.POST_NOTIFICATIONS (new) - so that your app can request permission from the user to display notifications (Android 13+)

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.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<!-- End Pushy Permissions -->

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

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 when they boot up
  2. me.pushy.sdk.services.PushySocketService - so that devices will be able to establish an idle background connection with our service
  3. 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
  4. me.pushy.sdk.receivers.PushyUpdateReceiver - so that devices maintain a background connection when your app gets updated, or when the device is in Doze mode

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" android:stopWithTask="false" />

<!-- 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:stopWithTask="false" />

<!-- End Pushy Declarations -->

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