Push Notifications

Games may use their own server to send Push Notifications to clients. If a game does not have a server Swrve may be leveraged to provide push notifications. There may also be cases where though a game has a server, you prefer to use Swrve to schedule notifications.

iOS Setup

There is not a whole lot to do for iOS to support PNs. We simply need to generate the certificate and ensure builds have the proper entitlement.

  1. Work with the producer to generate an APNS Certificate.
  2. Be sure the builds you deliver are provisioned with the aps-environment: production entitlement. To do this, you’ll need to enable PNs for the App Id of your shadow project (see Configuring Push Notifications).
  3. Send push notifications:
    • (Option A) If using your own server, your producer will provide you with the APNS Certificate generated in step 1 and you will handle configuring and sending PNs from your server.
    • (Option B) If using Swrve, export the APNS Certificate and deliver it and the password to the producer. The producer will use Swrve to configure, test, and send notifications.

NOTE: by default Swrve is configured to handle Push Notifications and the SDK auto collects the device token. If you use your own implementation, you may need to disable this. Include the following in your API settings to do so:

NSDictionary* apiSettings = @{ ...
[KongregateAPI initialize:gameId apiKey:apiKey withSettings:apiSettings];


If Swrve is used on Android, a few additional entries will need to be added to the Android manifest and your Sender ID will need to be included with the Kongregate API initiailization. If you have your own server, you only need the producer to provide you with the Sender ID, and the rest is up to you.

<!-- these permissions are required for Swrve Push Notifications -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" />
<!-- Configure the aspect of the UI -->

<!-- These @drawables refer to icons in your res directory. The Unity default is @drawable/app_icon -->
<meta-data android:name="SWRVE_PUSH_ICON" android:resource="@drawable/ic_launcher"/>
<meta-data android:name="SWRVE_PUSH_ICON_MATERIAL" android:resource="@drawable/ic_launcher_material"/>
<meta-data android:name="SWRVE_PUSH_ICON_LARGE" android:resource="@drawable/ic_launcher_large" />
<meta-data android:name="SWRVE_PUSH_ACCENT_COLOR" android:resource="@android:color/black" />

<!-- This is a reference to the activity to open when the push is followed. The Unity default is
     com.unity3d.player.UnityPlayerNativeActivity -->
<meta-data android:name="SWRVE_PUSH_ACTIVITY" android:value=".MainActivity"/>
<meta-data android:name="SWRVE_PUSH_TITLE" android:value="Your app title"/>

<!-- Add entries for Swrve receiver and intent service -->
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" 
		  android:permission="com.google.android.c2dm.permission.SEND" >
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <category android:name="YOUR_PACKAGE_NAME" />
<service android:name="com.kongregate.android.api.swrve.KongSwrveGcmIntentService">
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  android:exported="false" >
    <action android:name="com.google.android.gms.iid.InstanceID" />

<!-- The SwrveWakefulReceiver will automatically be pulled in for Gradle builds. For Library
     project and Unity plugin builds you will need to add the following to your manifest.
     Replace ${applicationId} with your package name -->
<receiver android:exported="false" android:name="com.swrve.sdk.SwrveWakefulReceiver">
        <action android:name="${applicationId}.swrve.SwrveWakeful" />

Android Example

Map<String,Object> apiOptions = new HashMap<String,Object>();
... // set other API options
APIBootstrap.initializeNativeAPI(activity, gameId, apiKey, apiOptions);

Unity Example

KongregateAPI.Settings.SwrveConfig = new Dictionary<string,object>() {
... // set other API options
KongregateAPI.Initialize(gameId, apiKey);

Air Example

KongregateAPI.settings.swrveConfig = {
  "senderId": "648571852960"
... // set other API options
KongregateAPI.initialize(root.stage, gameId, apiKey);


To verify everything is working properly, use the Swrve QA Devices and the Swrve Dashboard to send some test push notifications to yourself.