Skip to content

Commit 4d27482

Browse files
committed
added async to switch statement
1 parent a9eef29 commit 4d27482

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

docs/mini-apps/core-concepts/notifications.mdx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ Notification tokens are unique to each client app. This means a user can have se
5555
// Return appropriate error responses with status codes 400, 401, or 500
5656
}
5757

58-
//Return success immediately BEFORE processing
59-
//This allows Neynar to mark the token as active
60-
const response = Response.json({ success: true })
61-
6258

6359
// Extract webhook data
6460

@@ -67,13 +63,13 @@ Notification tokens are unique to each client app. This means a user can have se
6763
const event = data.event;
6864

6965
// Handle different event types
70-
(async () => {
66+
7167
try {
7268
switch (event.event) {
7369
case "miniapp_added":
7470
if (event.notificationDetails) {
75-
await setUserNotificationDetails(fid, appFid, event.notificationDetails);
76-
await sendMiniAppNotification({
71+
setUserNotificationDetails(fid, appFid, event.notificationDetails);
72+
sendMiniAppNotification(fid, appFid, "Welcome to Base Mini Apps", "Mini app is now added to your client");
7773
fid,
7874
appFid,
7975
title: "Welcome to Base Mini Apps",
@@ -106,11 +102,9 @@ Notification tokens are unique to each client app. This means a user can have se
106102
} catch (error) {
107103
console.error("Error processing webhook:", error);
108104
}
109-
})();
110105

111-
return response; // Neynar gets success immediately
106+
return response;
112107

113-
}
114108
```
115109
</Step>
116110
<Step title="Add the Webhook URL to your manifest">
@@ -147,7 +141,7 @@ Notification tokens are unique to each client app. This means a user can have se
147141
Webhooks must respond within 10 seconds to avoid timeouts from the Base app. If you encounter a "Failed to add mini app" error, your webhook may be taking too long to respond.
148142

149143
Different client apps handle webhook responses differently:
150-
144+
151145
**Farcaster app**: Does not wait for webhook responses and does not require a success response to activate notification tokens
152146

153147
**Base app**: Waits for the webhook to return a success response before activating the notification token.

0 commit comments

Comments
 (0)