我正在尝试在 Next.js (firebase v9) 中实现并导出 firebase 分析模块
对于以下代码片段,我收到错误“ReferenceError:窗口未定义” 。之前的所有功能都运行良好。
任何想法如何解决这一问题?
import { initializeApp, getApps, getApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getAuth } from 'firebase/auth'
import { getFirestore } from '@firebase/firestore'
const firebaseConfig = {
//...
};
// Initialize Firebase
const app = !getApps().length ? initializeApp(firebaseConfig) : getApp();
const auth = getAuth();
const db = getFirestore(app)
// try to add analytics
const analytics = getAnalytics(app)
export {auth, db, analytics}
Run Code Online (Sandbox Code Playgroud) 仅当打开应用程序并执行通知单击时,通知单击才会启动指定的活动。如果应用程序在后台运行/未运行,并且执行了单击通知,则将打开应用程序的MainActivity。简而言之,就像应用程序通常在活动堆栈之后打开,而不是在PendingIntent中打开指定的活动。
我想根据其类型将通知点击重定向到两个不同的活动(ApprovalDetailActivity和ConversationDetailActivity)。
我正在使用FCM进行推送通知。我在这里粘贴清单文件和FCMListener文件。请帮帮我。
MyFirebaseMessagingService.java中的sendNotification()函数
private void sendNotification(String messageBody)
{
Intent intent;
System.out.println("----message body: " + messageBody);
if(notificationBundle.getCategory().equalsIgnoreCase(Master.KEY_PUSH_NOTIFICATION_CONVERSATION))
{
intent = new Intent(this, ConversationDetailActivity.class);
/*Conversation conversation = Master.notificationBundle.getConversation();
Master.conversationsList = new ArrayList<>();
Master.conversationsList.add(conversation);*/
}
else
{
intent = new Intent(this, ApprovalDetailActivity.class);
if(notificationBundle.getApprovalType().equals("I"))
intent.putExtra(Master.KEY_WHICH_APPROVAL, Master.KEY_VERIFICATIONS);
else if(notificationBundle.getApprovalType().equals("A"))
intent.putExtra(Master.KEY_WHICH_APPROVAL, Master.KEY_APPROVALS);
else
intent.putExtra(Master.KEY_WHICH_APPROVAL, Master.KEY_COMPLETED);
intent.putExtra(Master.KEY_IS_FROM_CONVERSATION, false);
}
intent.putExtra(Master.KEY_PUSH_NOTIFICATION_POST_ID , notificationBundle.getPostID());
intent.putExtra(Master.KEY_IS_FROM_PUSH_NOTIFICATION, true);
intent.putExtra(Master.KEY_POSITION, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.mnet_icon)
.setContentTitle(getString(R.string.app_name)) …Run Code Online (Sandbox Code Playgroud) notifications android push-notification firebase-cloud-messaging
如何在android studio中访问java资源中的静态变量strings.xml?
我有一个像这样的变量:
public static final String NUM_OF_DAYS = "10";
Run Code Online (Sandbox Code Playgroud)
现在,我想以某种方式在strings.xml资源中使用它.
编辑:
我只想在java文件中使用string.xml资源(将访问NUM_OF_DAYS).
我正在尝试从Amazon S3获取存储桶的commonPrefixes。我正在使用以下代码来获取所有对象的列表:
ObjectListing listing = s3Client.listObjects(new ListObjectsRequest().withBucketName(bucket).withPrefix("used/").withDelimiter("/"));
for (String name : listing.getCommonPrefixes())
{
System.out.println(name);
objectNames.add(name);
}
System.out.println("\n\n\nSize: " + objectNames.size());
Run Code Online (Sandbox Code Playgroud)
但这只是打印一些commonPrefixes。有超过2000个前缀,但仅打印950。如何获得所有前缀?