npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-dxp-rn-platform

v0.0.2

Published

dxp platform

Readme

DXP React Native SDK

DXP (Digital Experience Platform) SDK 的 React Native 封装,提供完整的数字体验平台功能。

📋 功能特性

  • SDK初始化和配置 - 支持完整的配置选项
  • 用户认证 - 登录/登出功能
  • 站内信管理 - 消息列表、未读数量、已读标记、删除等
  • 埋点上报 - 支持 Google Analytics 和神策埋点
  • 营销广告 - 自动化广告弹窗管理
  • 推送消息 - Firebase/HMS 推送支持
  • 平台判断 - 自动检测和适配不同平台
  • TypeScript 支持 - 完整的类型定义

🎯 平台支持

| 平台 | 状态 | 说明 | |------|------|------| | Android | ✅ 完全支持 | 所有功能可用 | | iOS | ⚠️ 部分支持 | 接口已预留,等待iOS SDK完善 |

📦 安装

npm install react-native-dxp-rn-platform

# 或使用 yarn
yarn add react-native-dxp-rn-platform

Android 配置

1. 添加 Maven 仓库

在项目根目录的 android/build.gradle 中添加:

allprojects {
    repositories {
        maven {
            url 'https://maven.pkg.github.com/iWhaleCloud/DXP'
            credentials {
                username = 'wctrepo'
                password = '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'
            }
        }
    }
}

2. 添加权限

android/app/src/main/AndroidManifest.xml 中添加:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

iOS 配置

iOS 平台目前仅提供占位实现,具体配置将在 iOS SDK 完善后提供。

🚀 使用示例

基础使用

import DxpSdk, { DxpInbox, DxpTrace, DxpPromotion, DxpPush, TraceType } from 'react-native-dxp-rn-platform';

// 1. 初始化 SDK
const config = {
  dxpUrl: 'https://your-dxp-server.com',
  clientKey: 'your_client_key',
  logConfig: {
    enableLog: true,
    logLevel: 3 // DEBUG
  },
  eventTraceConfig: {
    url: 'https://your-sensors-server.com',
    traceType: TraceType.ONLY_SHEN_CE,
    tracePublicProperties: {
      app_name: 'Your App',
      app_version: '1.0.0'
    }
  }
};

try {
  const result = await DxpSdk.initializeSdk(config);
  console.log('SDK 初始化成功:', result);
} catch (error) {
  console.error('SDK 初始化失败:', error);
}

// 2. 用户登录
await DxpSdk.login('customer_number', null, 123456789, {
  onLoginSuccess: (response) => {
    console.log('登录成功:', response);
  },
  onLoginError: (resultCode, resultMsg) => {
    console.error('登录错误:', resultCode, resultMsg);
  },
  onLoginFailed: (errorMsg) => {
    console.error('登录失败:', errorMsg);
  }
});

// 3. 使用功能模块
await DxpInbox.openInbox(); // 打开站内信
await DxpTrace.trace({ eventName: 'button_click' }); // 发送埋点

平台检查

// 获取平台信息
const platformInfo = DxpSdk.getPlatformInfo();
console.log('平台信息:', platformInfo);

// 检查平台支持
if (platformInfo.hasFullSupport) {
  // 使用完整功能
  await DxpTrace.init();
  await DxpPromotion.init();
} else {
  console.warn('当前平台功能有限');
}

📚 主要API

DxpSdk (主要SDK)

  • initializeSdk(config) - 初始化SDK
  • login(custNbr, serviceNumber, subsId, callbacks) - 用户登录
  • logout(pushToken, pushProvider, callbacks) - 用户登出
  • isLoggedIn() - 检查登录状态
  • getPlatformInfo() - 获取平台信息

DxpInbox (站内信)

  • openInbox() - 打开站内信列表
  • queryUnreadMessageCount(callbacks) - 查询未读消息数量
  • listMessages(pageNo, pageSize, callbacks) - 查询消息列表
  • markMessagesAsRead(messageIds, callbacks) - 标记消息为已读

DxpTrace (埋点)

  • init() - 初始化埋点模块
  • trace(eventData) - 发送埋点事件
  • addSuperProperties(properties) - 添加公共属性

DxpPromotion (营销广告)

  • init() - 初始化营销广告模块
  • showPromotion() - 手动显示广告
  • setPromotionLifecycleListener(listener) - 设置生命周期监听器

DxpPush (推送消息)

  • ensureDefaultChannel() - 确保默认通知渠道
  • reportFirebasePushToken(token) - 上报Firebase Token
  • setDeepLinkHandler(handler) - 设置深链接处理器

📖 示例应用

项目包含一个完整的示例应用,展示了所有SDK功能的使用方法。

运行示例

# 进入示例目录
cd example

# 安装依赖
yarn install

# 运行iOS
yarn ios

# 运行Android
yarn android

⚠️ 注意事项

  1. Android 平台:功能完整,可在生产环境使用
  2. iOS 平台:目前仅提供占位实现,等待原生iOS SDK完善
  3. 网络权限:确保应用有网络访问权限
  4. Maven仓库:Android需要配置DXP SDK的Maven仓库访问权限

🏗️ 项目结构

dxp-rn-platform/
├── src/
│   ├── index.tsx           # 主要SDK接口
│   └── utils/
│       └── PlatformUtils.js # 平台工具类
├── android/                # Android原生模块
├── ios/                    # iOS原生模块(占位实现)
├── example/                # 示例应用
└── README.md

📞 技术支持

如有问题或建议,请:

  1. 查看示例应用了解使用方法
  2. 提交 Issue 报告问题
  3. 联系开发团队获取支持

License

MIT