From 6532bc2cb586b7d3a6d19ad89c4099e29dd8ef61 Mon Sep 17 00:00:00 2001 From: panyinan Date: Wed, 7 Feb 2024 10:19:51 +0800 Subject: [PATCH] =?UTF-8?q?[Issues:=20#I91C0R]=20=E6=B7=BB=E5=8A=A0react-n?= =?UTF-8?q?ative-community-push-notification-ios=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-native-community-push-notification-ios.md | 377 ++++++++++++++++++ 1 file changed, 377 insertions(+) create mode 100644 1224/react-native-community-push-notification-ios.md diff --git a/1224/react-native-community-push-notification-ios.md b/1224/react-native-community-push-notification-ios.md new file mode 100644 index 00000000..17dbcf71 --- /dev/null +++ b/1224/react-native-community-push-notification-ios.md @@ -0,0 +1,377 @@ +> 模板版本:v0.1.3 + +

+

@react-native-community/push-notification-ios

+

+

+ + Supported platforms + + + License + +

+ +> [!TIP] [Github 地址](https://github.com/react-native-push-notification/ios) + +## 安装与使用 + +进入到工程目录并输入以下命令: + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/push-notification-ios@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/push-notification-ios@file:# +``` + + + + +下面的代码展示了这个库的基本使用场景: + +>[!WARNING] 使用时 import 的库名不变。 + +```js +import React, { useState } from 'react'; +import { + View, + Text, + Button +} from 'react-native'; + +import PushNotification from '@react-native-community/push-notification-ios'; + +export const App = () => { + + const [data, setData] = useState({}); + + const addNotificationRequest = () => { + PushNotification.addNotificationRequest({ + id: 'test', + title: 'title', + subtitle: 'subtitle', + body: 'body', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 2000), + repeats: true, + userInfo: { + image: 'https://www.github.com/Naturalclar.png', + } + }); + }; + + const addSilentNotificationRequest = () => { + PushNotification.addNotificationRequest({ + id: 'test-4', + title: 'title', + subtitle: 'subtitle', + body: 'body', + category: 'test', + isSilent: true, + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 2000), + repeats: true, + userInfo: { + image: 'https://www.github.com/Naturalclar.png', + } + }); + }; + + const addMultipleRequests = () => { + PushNotification.addNotificationRequest({ + id: 'test-1', + title: 'First', + subtitle: 'subtitle', + body: 'First Notification out of 3', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 10000), + repeats: true, + }); + + PushNotification.addNotificationRequest({ + id: 'test-2', + title: 'Second', + subtitle: 'subtitle', + body: 'Second Notification out of 3', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 12000), + repeats: true, + }); + + PushNotification.addNotificationRequest({ + id: 'test-3', + title: 'Third', + subtitle: 'subtitle', + body: 'Third Notification out of 3', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 14000), + repeats: true, + }); + }; + + const removeAllDeliveredNotifications = () => { + PushNotification.removeAllDeliveredNotifications(); + }; + + const removeDeliveredNotifications = () => { + PushNotification.removeDeliveredNotifications(['test-1', 'test-2']); + }; + + const getDeliveredNotifications = () => { + PushNotification.getDeliveredNotifications((data) => { + if (data) { + setData(data) + } else { + console.log("failed"); + } + }); + }; + + + return ( + +