code: LifecycleListener createLifecycleListener(final WeakReference<ComapiChatClient> ref) {
  
          return new LifecycleListener() {
  
              /**
               * App foregrounded.
               *
               * @param context Application context
               */
              public void onForegrounded(Context context) {
                  ComapiChatClient client = ref.get();
                  if (client != null) {
                      client.service().messaging().synchroniseStore(null);
                  }
              }
  
              /**
               * App backgrounded.
               *
               * @param context Application context
               */
              public void onBackgrounded(Context context) {
  
              }
          };
      }
docs: Creates listener for Application visibility.
  
  @param ref Weak reference to comapi client used to trigger synchronisation in response to app being foregrounded.
  @return Listener to app lifecycle changes.