* Switch to SingleDex and remove all locales * WIP Mattermost Start Component for lazy loading modules * Add files changed for native modules * Add Entry component and app global object * dispatch setStatusBarHeight for iOS * Update screen imports * Include Entry screen * Refactor app to mattermost.android.js * Override unnecessary java files * Fix minor issues in changes * Display empty state based on user credentials Also, add proper background theme for empty loading screen * Add native module constant cache support * Fix startup theme regression * Add Keychain support for credentials * Fix Orientation regression * Fix SharedExtension regression * Emit NATIVE_APP_LAUNCHED across bridge only once during cold start * Add iOS Support * Revert to previous implementation of i18n * Fix styling issues * Include listener for SERVER_VERSION_CHANGED * Add SafeAreaView in Entry screen * Register deviceToken early, in order to get iOS PN Support * Include StartTimeModule * Add ReplyFromPush support and remove NATIVE_APP_LAUNCHED listener * Package native constants in StartTimeModule and avoid bridge calls * Fix check-style errors * Code cleanup * Rename StartTimeModule to InitializationModule * Remove NavigationApplication * Documentation and minor changes * Account for app opening after SharedExtension * Refactor getIntl to getTranslations * Move native module constants into it's own forked repos * Include FetchBlob and DeviceInfo forked repos
55 lines
2 KiB
Java
55 lines
2 KiB
Java
package com.mattermost.rnbeta;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.app.NotificationManager;
|
|
import android.app.RemoteInput;
|
|
import android.os.Bundle;
|
|
import android.support.annotation.Nullable;
|
|
import android.util.Log;
|
|
|
|
import com.facebook.react.HeadlessJsTaskService;
|
|
import com.facebook.react.bridge.Arguments;
|
|
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
|
|
|
|
|
|
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
|
|
|
|
public class NotificationReplyService extends HeadlessJsTaskService {
|
|
private Context mContext;
|
|
|
|
@Override
|
|
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
|
|
mContext = getApplicationContext();
|
|
if (CustomPushNotification.KEY_TEXT_REPLY.equals(intent.getAction())) {
|
|
CharSequence message = getReplyMessage(intent);
|
|
|
|
Bundle bundle = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
|
|
String channelId = bundle.getString("channel_id");
|
|
bundle.putCharSequence("text", message);
|
|
bundle.putInt("msg_count", CustomPushNotification.getMessageCountInChannel(channelId));
|
|
|
|
int notificationId = intent.getIntExtra(CustomPushNotification.NOTIFICATION_ID, -1);
|
|
CustomPushNotification.clearNotification(mContext, notificationId, channelId);
|
|
|
|
MainApplication app = (MainApplication) this.getApplication();
|
|
app.replyFromPushNotification = true;
|
|
Log.i("ReactNative", "Replying service");
|
|
return new HeadlessJsTaskConfig(
|
|
"notificationReplied",
|
|
Arguments.fromBundle(bundle),
|
|
5000);
|
|
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private CharSequence getReplyMessage(Intent intent) {
|
|
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
|
|
if (remoteInput != null) {
|
|
return remoteInput.getCharSequence(CustomPushNotification.KEY_TEXT_REPLY);
|
|
}
|
|
return null;
|
|
}
|
|
}
|