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

react-native-tim

v1.0.33

Published

tencent im sdk

Downloads

6

Readme

腾讯云通讯

使用方法见index.js

安装

npm install @anren/react-native-tim
rnpm link

ios配置

xcode工程->BuildPhases->Link Binary With Libraries->添加以下库

  • CoreTelephony.framework
  • SystemConfiguration.framework
  • libc++
  • libz
  • libsqlite3

####离线推送配置

1.首先要在工程->Build Settings->Header Search Paths中添加模块所在位置:$(SRCROOT)/../node_modules/react-native-tim/ios,设置为recursive.

2.AppDelegate.m中添加头文件#import "RCTTIM/RCTTIMPush.h"

3.在AppDelegate.m的didFinishLaunchingWithOptions方法中添加如下代码,注意如果有其他推送模块已经添加了获取token的相关代码,则不需要填写

//didFinishLaunchingWithOptions方法中添加获取token代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	...
	
	[RCTTIMPush registerForRemoteNotifications];
	
	...
}

4.添加如下三个方法:

//收到token,将token级busiId传递给RCTTIM模块。busiID为腾讯分配,
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
#if DEBUG
	//开发环境
	[RCTTIMPush registerDeviceToken:deviceToken withBusiId:TIM_BUSIID_DEV];
#else
	//生产环境
	[RCTTIMPush registerDeviceToken:deviceToken withBusiId:TIM_BUSIID_PRO];
#endif
}

//收到通知
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
	[RCTTIMPush didReceiveNotification:userInfo];
}

//收到通知(for ios7)
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
	[RCTTIMPush didReceiveNotification:userInfo];
}

android配置

AndroidManifest.xml 中添加以下权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

并在中添加以下配置

<!--  消息收发service -->
<service
	android:name="com.tencent.qalsdk.service.QalService"
	android:exported="false" 
	android:process=":QALSERVICE" >  
</service> 
<!--  消息收发辅助service -->
<service  
	android:name="com.tencent.qalsdk.service.QalAssistService"  
	android:exported="false"
	android:process=":QALSERVICE" >
</service> 
<!--  离线消息广播接收器 -->
<receiver 
	android:name="com.tencent.qalsdk.QALBroadcastReceiver" 
	android:exported="false">
	<intent-filter>
    	<action android:name="com.tencent.qalsdk.broadcast.qal" />
	</intent-filter>
</receiver>
<!--  系统消息广播接收器 -->
<receiver 
	android:name="com.tencent.qalsdk.core.NetConnInfoCenter" 
	android:process=":QALSERVICE">  
	<intent-filter>
    	<action android:name="android.intent.action.BOOT_COMPLETED" />
	</intent-filter>
	<intent-filter>
    	<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
	</intent-filter>
	<intent-filter>
    	<action android:name="android.intent.action.TIME_SET" />
	</intent-filter>
	<intent-filter>
    	<action android:name="android.intent.action.TIMEZONE_CHANGED" />
	</intent-filter>
</receiver>

MainApplication.java的添加如下代码

//getPackages添加下面一行,参数代表图标icon资源ID
new TIMPackage(R.mipmap.ic_launcher)

消息结构

消息共分为两部分:

  • 消息基础信息
  • 消息元素

示例如下:

// message struct
{
	msgId: 'sadfasdf', 	//消息id
	isSelf: false,		//是否自己发送
	hasGap: false,		//是否存在消息断层,如果存在建议调用getMessage获取丢失消息。
	eleCount: 1,			//消息元素个数
	isReaded: false,		//是否已读
	sender: 'asdasd'		//发送者id
	timestamp: 1239012309,	//创建时间
	elems: [				//消息元素,数组,可能多个
		//文本元素
		{
			type:'text',
			data:'hello world.'
		}
	]
}

消息元素有以下几种类型:

  • text 文本信息
  • custom 自定义信息,子类型为image,audio及其他命令信息
  • groupSystem 群系统消息,子类型(subType字段)参见腾讯官网
  • groupTips 群提示信息,子类型(subType字段)参见腾讯官网

以上信息分别有不同的结构,具体参见官网。