嘿,我正在使用 React Navigation 中的 createBottomTabNavigator(),并且我有一个自定义顶栏,我用自己的状态更新它。问题是,当我单击选项卡时,每次导航都会调用侦听器,因此如果您转到屏幕 2,则顶部栏会进入错误的状态,顶部栏会更改为屏幕 2。当我按下顶部栏后退按钮时,它会返回到屏幕 1 并将顶部栏更改为屏幕 1 顶部栏。现在,如果我使用底部栏选项卡而不是使用顶部栏选项卡向后导航,它会使顶部栏远离屏幕 2。所以我的问题是,如果我按底部栏,它会导航回初始屏幕,我是否可以以某种方式禁用它1.
<Tab.Screen
listeners={() => {
switchTab(0);
}}
name="Input"
children={() => (
<SuchStackContainer
ref={suchStackRef}
switchStack={switchStack}
listings={listings}
setListings={setListings}
/>
)}
options={{
tabBarLabel: 'Suche',
tabBarIcon: ({color, size}) => (
<Ionicons name="car" color={color} size={size} />
),
}}
/>
Run Code Online (Sandbox Code Playgroud) react-native react-native-navigation react-navigation react-navigation-bottom-tab
您好,我正在尝试快速读取推送通知的标题或正文变量。出于测试目的,我创建了一个 .apns 文件,并使用 xcrun 运行该文件
apns 文件如下所示:
{
"aps" : {
"alert" : {
"title" : "Dein Freund ist am Joggen",
"body" : "Schick ihm ne Anfrage bro ",
"action-loc-key" : "PLAY"
},
"badge" : 5
},
"acme1" : "bar",
"acme2" : [ "bang", "whiz" ]
}
Run Code Online (Sandbox Code Playgroud)
这是我用于推送通知按下的功能。Userinfo 是完整的消息,它返回此代码下方的输出。现在我需要 .title 或 .body 变量,如何获取它们?
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] …
Run Code Online (Sandbox Code Playgroud) 嘿,我正在尝试升级到 firebase 云函数 v2,但是当尝试更改代码时,我注意到我的函数不再像 v1 那样具有 .region。
这是 v1 版本,我可以在其中调用 .region 并更改它
import * as functions from "firebase-functions";
exports.helloWorld = functions.region("europe-west1").https.onCall(() => {
functions.logger.info("Hello logs!", { structuredData: true });
return { text: "Hello from Firebase!" };
});
Run Code Online (Sandbox Code Playgroud)
现在我升级到 v2,但我得到:
Property 'region' does not exist on type
'typeof import("/.../node_modules/firebase-functions/lib/v2/index")
Run Code Online (Sandbox Code Playgroud)
尝试为 firebase 云功能 v2 实现类似的功能有什么想法吗?
import { https, logger } from "firebase-functions/v2";
import * as functions from "firebase-functions/v2";
// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
const regionalFunctions = functions.region("europe-west1"); …
Run Code Online (Sandbox Code Playgroud) node.js firebase google-cloud-platform google-cloud-functions
嘿,我正在尝试在这里对这个云功能进行单元测试:
import { logger, region, https } from "firebase-functions/v1";
import Message from "../types/message";
const helloWorldHandler = region("europe-west1").https.onCall((_, context) => {
if (context.app == undefined) {
throw new https.HttpsError("failed-precondition", "The function must be called from an App Check verified app.");
}
logger.info("Hello logs!", { structuredData: true });
const message: Message = {
text: "Hello from Firebase!",
code: 200,
};
return message;
});
export default helloWorldHandler;
Run Code Online (Sandbox Code Playgroud)
通过以下测试:
import * as functions from "firebase-functions-test";
import * as path from "path";
const projectConfig = …
Run Code Online (Sandbox Code Playgroud) 嘿,我已经找到了如何上传到 firebase 存储中:
admin.initializeApp({
credential: secret,
databaseURL: secret,
storageBucket: secret,
});
var bucket = admin.storage().bucket();
const uploadToFireStorage = (filename, query, fileType, imageURL) => {
bucket.upload(filename).then(console.log("uploaded"));
};
Run Code Online (Sandbox Code Playgroud)
正如您通过我的bucket.upload 函数所看到的,我可以上传到firebase 存储,但它会上传到根文件夹中,我想将其放在/foodImages/myfile.png 下,例如有什么想法吗?
javascript google-cloud-storage firebase google-cloud-platform firebase-storage
firebase ×3
ios ×1
javascript ×1
node.js ×1
react-native ×1
react-navigation-bottom-tab ×1
swift ×1
uikit ×1