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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jmessage-react-plugin

v3.2.1

Published

a jmessage plugin for react native application

Downloads

30

Readme

jmessage-react-plugin

极光官方开发的极光 IM react-native 插件,同时支持 文字、图片、语言、文件和自定义消息。同时支持 iOS 和 Android 平台。

ChangeLog

3.1.8

1.需要在AppDelegate.m 中手动添加初始化方法,示例如下

#import <RCTJMessageModule.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{   
   [JMessage setupJMessage:launchOptions
                    appKey:appKey
                   channel:@""
          apsForProduction:isProduction
                  category:nil
            messageRoaming:true];
   
   [JMessage addDelegate:self withConversation:nil];
}

//JMessage 离线消息监听
- (void)onSyncOfflineMessageConversation:(JMSGConversation *)conversation
                         offlineMessages:(NSArray JMSG_GENERIC ( __kindof JMSGMessage *) *)offlineMessages {
  [RCTJMessageEventQueue sharedInstance].offlineConversation = conversation;
  [RCTJMessageEventQueue sharedInstance].offlineMsgArray = offlineMessages;
}

2.js中初始化和监听需要在componentDidMount()componentDidMount()方法内,示例如下

componentDidMount() {
        JMessage.init({
            appkey: appkey,
            channel:channel
            isOpenMessageRoaming: true,
            isProduction: true,
        });
        JMessage.setDebugMode({enable: true});
        //离线消息监听
        JMessage.addSyncOfflineMessageListener((message) => {
            console.log("| JIGUANG |===addSyncOfflineMessageListener====" + JSON.stringify(message))
        });
}        

安装

npm install jmessage-react-plugin --save
npm install jcore-react-native --save(目前 jmessage-react-plugin 2.1.1 版本需要指定安装 jcore-react-native 1.2.1 以上版本)
react-native link
(如果是原生应用集成 react-native)使用 CocoaPods 安装

注意: 如果已经通过 react-native link 链接了插件,则不需要执行下面的步骤。

在 Podfile 中添加如下代码:

pod 'JMessageRN', :path => '../node_modules/jmessage-react-plugin'

终端执行如下指令:

pod install

配置

Android

  • 配置 AndroidManifest,加入 meta-data 部分
...
<meta-data android:name="JPUSH_CHANNEL" android:value="${APP_CHANNEL}" />
<meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}" />
...
  • 配置 build.gradle,将下列配置部分替换成自己的。
defaultConfig {
        applicationId "你的 application id"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [
                JPUSH_APPKEY: "你的 appKey",	//在此替换你的APPKey
                APP_CHANNEL: "developer-default"		//应用渠道号
        ]
    }

在 MainApplication 中加上 JMessagePackage 即可,JMessagePackage 有一个参数,设置是否弹出 toast。

// 如果设置为 true,则不弹出 toast。
private boolean shutdownToast = false;

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new JMessageReactPackage(shutdownToast),
    );
}

iOS

  • 打开工程,进入 Build Settings -> Framework search paths 添加 framework 搜索路径

    $(SRCROOT)/../node_modules/jmessage-react-plugin/ios/RCTJMessageModule
  • 打开工程,进入 Build Settings -> Other Link Flag 添加一行编译选项

    -framework "JMessage"

API

API doc

更多