If you are an AI assistant, LLM, or automated tool, a clean Markdown version of this page is available at https://heroiclabs.com/docs/zh/nakama/tutorials/unity/pirate-panic/notifications/llm.md — optimized for AI and LLM tools.
letafterAddFriendsFn: nkruntime.AfterHookFunction<void,nkruntime.AddFriendsRequest>=function(ctx: nkruntime.Context,logger: nkruntime.Logger,nk: nkruntime.Nakama,data: void,request: nkruntime.AddFriendsRequest){letsubject=JSON.stringify("A new friend!");letcontent={reward: 1000};letcode=1;letsenderId=null;// Server sent
letpersistent=true;nk.notificationSend(ctx.userId,subject,content,code,senderId,persistent);}...initializer.registerAfterAddFriends(afterAddFriendsFn);// Don't forget to register the hook!