Modify AndroidManifest
Declare permissions, services, and receivers in your app's AndroidManifest.xml
file.
Declare Permissions
Our SDK requires the following permissions:
android.permission.INTERNET
- so that devices will be able to connect to our serviceandroid.permission.WAKE_LOCK
- so that devices won't disconnect their Wi-Fi connection during sleepandroid.permission.ACCESS_NETWORK_STATE
- so that the SDK will be able to check for an active Internet connectionandroid.permission.RECEIVE_BOOT_COMPLETED
- so that devices will reconnect after they finish booting upandroid.permission.POST_NOTIFICATIONS
(new) - so that your app can request permission from the user to display notifications (Android 13+)android.permission.SCHEDULE_EXACT_ALARM
(new) - so that the connection can be kept active during Doze mode (Android 12+)
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" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<!-- 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
:
me.pushy.sdk.receivers.PushyBootReceiver
- so that devices will reconnect when they boot upme.pushy.sdk.services.PushySocketService
- so that devices will be able to establish an idle background connection with our serviceme.pushy.sdk.services.PushyJobService
- so that devices running Android Oreo and up will be able to establish an idle background connection with our serviceme.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.