Parse Server

To use the Parse Server feature ,you must select an App plan with App Backend product provided

Prerequisites - Mobile App Project created on Appgain.io - SDK installed and configured in AppController

Steps to Follow: 1. Open Firebase console , Go to project settings
firbase project settings 2. Go to Cloud Messaging tab and copy SenderID and Legacy server key cloud settings 3. Open appgain dashboard 4. Go to APP BACKEND > Settings 5. Navigate to Android push tab 6. enter your SenderID and Server key Appgain Android Push settings

SDK configuration 1. Setup SDK in AppController

AppgainSDKInitCallBack callback = new AppgainSDKInitCallBack() {
     @Override  
     public void onSuccess() {
         Log.d(TAG , "success initialization");  
      }
      @Override  
      public void onFail(BaseResponse failure) {
         Log.e(TAG , "faill initialization");  
      }  
  };  

 Appgain.initializeWithParseAnonymous(
     getApplicationContext(),
     APPGAIN_APP_ID,
     APPGAIN_API_KEY,
     PARSE_APP_ID,
     PARSE_SERVER_NAME,
     callback
  );

Or with user name

 Appgain.initializeWithParse(
      getApplicationContext() ,
      APPGAIN_APP_ID,
      APPGAIN_API_KEY,
      PARSE_APP_ID,
      PARSE_SERVER_NAME,
      new User("username" , "password" , "email")
      callback
  );
  1. Adding permission to your manifest
<uses-permission android:name="android.permission.INTERNET" />
  1. inside your application tag add
    <service  
        android:name="com.parse.fcm.ParseFirebaseInstanceIdService"
        android:exported="true">  
        <intent-filter>  
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />  
        </intent-filter>  
    </service>  

    <service android:name="com.parse.fcm.ParseFirebaseMessagingService">  
        <intent-filter>  
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>  
        </intent-filter>  
    </service>



    <meta-data  
        android:name="com.parse.push.notification_icon"  
        android:resource="@drawable/ic_app_notfication" />

  1. Create new class MyPushReceiver which extend AppGainPushReceiver and implement onReceive method
public class MyPushReceiver extends AppGainPushReceiver {  
    @Override  
    protected void onReceive(Context context, ReceiveStatus receiveStatus, Intent intent) {  
    // doing some action after receiving  
    }  
}
  1. Make receiver with your new class in your application tag in Manifest file


<application
    ....
    >  
    <receiver  
    android:name=".MyPushReceiver"  
    android:exported="false">  
    <intent-filter>  
    <action android:name="com.parse.push.intent.RECEIVE" />  
    <action android:name="com.parse.push.intent.DELETE" />  
    <action android:name="com.parse.push.intent.OPEN" />  
    </intent-filter>  
    </receiver>
    ....
</application>
  1. Our PushNotification working on Firebase PushNotification Data key which is manly for foreground app so to you can our background battery optimize helper function to make sure it will be deliver on foreground and background

    Add ignore battery optimization permission to your manifest xml <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> To use helper method java PowerUtils.startPowerMangerIntents(this , getString(R.string.allow_background)); 7. Finally, you can change status of app push notification for user to enable or disable it

     boolean enable = false ; 
      NotificationChannelUtils.changeNotificationStatus("appPush", enable, new UpdateNotificationCallBack() {  
      @Override  
      public void onSuccess() {  
      // log success  
      }  

      @Override  
      public void onFailure(BaseResponse failure) {  
      // log failure  
      }  
    });

Or you can change all notifications channels status (appPush , webPush , email , SMS ) ```java
boolean enable = false ; NotificationChannelUtils.changeAllNotificationStatus(enable, new UpdateNotificationCallBack() {
@Override
public void onSuccess() {
// log success

  }

  @Override  
  public void onFailure(BaseResponse failure) {  
  // log failure  
  }  
});

```