/**
   * This function used to register GCM device Token on AppHQ
   *
   * @param userName
   * @param deviceToen
   * @param callBack
   */
  public static void registerOnApp42(
      String userName, String deviceToen, final App42GCMListener callBack) {
    App42API.buildPushNotificationService()
        .storeDeviceToken(
            userName,
            deviceToen,
            new App42CallBack() {
              @Override
              public void onSuccess(Object arg0) {
                App42Response response = (App42Response) arg0;
                callBack.onRegisterApp42(response.getStrResponse());
              }

              @Override
              public void onException(Exception arg0) {
                // TODO Auto-generated method stub
                callBack.onApp42Response(arg0.getMessage());
              }
            });
  }
Пример #2
0
  private void registerWithApp42(String regId) {
    App42Log.debug(" Registering on Server ....");
    App42API.buildPushNotificationService()
        .storeDeviceToken(
            App42API.getLoggedInUser(),
            regId,
            new App42CallBack() {
              @Override
              public void onSuccess(Object paramObject) {
                // TODO Auto-generated method stub
                App42Log.debug(" ..... Registeration Success ....");
                GCMRegistrar.setRegisteredOnServer(App42API.appContext, true);
              }

              @Override
              public void onException(Exception paramException) {
                App42Log.debug(" ..... Registeration Failed ....");
                App42Log.debug("storeDeviceToken :  Exception : on start up " + paramException);
              }
            });
  }
  /**
   * Send a PushMessage to desired User
   *
   * @param userName
   * @param message
   * @param callBack
   */
  public static void sendPushToUser(
      String userName, String message, final App42GCMListener callBack) {
    App42API.buildPushNotificationService()
        .sendPushMessageToUser(
            userName,
            message,
            new App42CallBack() {

              @Override
              public void onSuccess(Object arg0) {
                // TODO Auto-generated method stub
                App42Response response = (App42Response) arg0;
                callBack.onApp42Response(response.getStrResponse());
              }

              @Override
              public void onException(Exception arg0) {
                // TODO Auto-generated method stub
                callBack.onApp42Response(arg0.getMessage());
              }
            });
  }