我对应用程序开发、Java 和 StackOverflow 完全陌生,这是我的第一个 Android 应用程序。
我已经实现了 OneSignal 用于推送通知传递。我只是想在通知中添加对操作按钮的支持。
我希望我的 SplashActivity 在用户触摸带有 ID:post 的 Action 按钮时启动,并且如果用户触摸带有 ID:app 的按钮,我希望在 Web 浏览器中启动一个 URL。
所以,这是我的 ApplicationClass.java:
package com.ananya.brokenhearts;
import android.app.Application;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import com.onesignal.OSNotificationAction;
import com.onesignal.OSNotificationOpenResult;
import com.onesignal.OneSignal;
import org.json.JSONObject;
public class ApplicationClass extends Application
{
@Override
public void onCreate()
{
super.onCreate();
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
}
private class NotificationOpenedHandler implements OneSignal.NotificationOpenedHandler
{
@Override
public void notificationOpened(OSNotificationOpenResult result)
{
OSNotificationAction.ActionType actionType = result.action.type;
JSONObject data = result.notification.payload.additionalData;
String customKey; …Run Code Online (Sandbox Code Playgroud) 我已经使用withDefaultsanddefineProps一段时间了,但突然开始失败,我不明白为什么!
我有一个基本的 SFC,例如:
<script
setup
lang = "ts">
const props = withDefaults(defineProps<{
foo : RegExp
}>(), {
foo: /./
})
</script>
<template>
<!-- rest of the stuff -->
</template>
Run Code Online (Sandbox Code Playgroud)
构建失败并出现以下错误:
error TS2322: Type 'RegExp' is not assignable to type '(props: Readonly<{ foo?: RegExp | undefined; }>) => RegExp'.
Type 'RegExp' provides no match for the signature '(props: Readonly<{ foo?: RegExp | undefined; }>): RegExp'.
14 foo: /./,
~~~
src/App.vue:11:5
11 foo?: RegExp;
~~~
The expected type …Run Code Online (Sandbox Code Playgroud)