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-umeng-push

v1.0.5

Published

``` rnpm install react-native-umeng-push ```

Downloads

35

Readme

#react-native-umeng-push ##安装

rnpm install react-native-umeng-push

##集成到iOS 在Appdelegate.m中对应的位置添加如下三个API:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  //注册友盟推送
  [RCTUmengPush registerWithAppkey:@"your app key" launchOptions:launchOptions];
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  //获取deviceToken
  [RCTUmengPush application:application didRegisterDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
  //获取远程推送消息
  [RCTUmengPush application:application didReceiveRemoteNotification:userInfo];
}

##集成到android 注意:0.29版本以后,reactNative会自动创建MainApplication,并且将添加原生模块从MainActivity移到了MainApplication,详情请见http://reactnative.cn/post/1774,所以我们的这里继承也有些变化,如果你的reactNative版本是0.29以下,请点击README-pre.md

####1、添加PushSDK 由于这个库依赖于react-native-umeng-sdk,需要在你的工程settings.gradle文件中添加PushSDK

include ':PushSDK'
project(':PushSDK').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-umeng-sdk/android/PushSDK')

####2、设置Application 新版本的react-native工程已经存在MainApplication,我们只需要将MainApplication继承UmengApplication,然后添加对应的UmengPushPackage进去就行了,如下所示:

import com.liuchungui.react_native_umeng_push.UmengPushApplication;
import com.liuchungui.react_native_umeng_push.UmengPushPackage;

public class MainApplication extends UmengPushApplication implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

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

注:这一步主要是因为友盟推送需要在Application当中接收推送,UmengPushApplication封装了友盟推送的内容。如果友盟推送如果不放在Application当中,退出应用之后是无法接收到推送的。

####3、添加AppKey & Umeng Message Secret 在项目工程的AndroidManifest.xml中的标签下添加:

<meta-data
    android:name="UMENG_APPKEY"
    android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" >
</meta-data>
<meta-data
    android:name="UMENG_MESSAGE_SECRET"
    android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" >
</meta-data>

####4、其它 **注:**如果是android6.0以上的api编译,需要在PushSDK的build.gradle文件的android{}块内添加useLibrary 'org.apache.http.legacy',并把compileSdkVersion的版本号改为23。

详情参考:友盟安卓SDK集成指南

##API

| API | Note |
|---|---| | getDeviceToken | 获取DeviceToken | | didReceiveMessage | 接收到推送消息回调的方法 | | didOpenMessage | 点击推送消息打开应用回调的方法 |

##Usage

import UmengPush from 'react-native-umeng-push';

//获取DeviceToken
UmengPush.getDeviceToken(deviceToken => {
    console.log("deviceToken: ", deviceToken);
});

//接收到推送消息回调
UmengPush.didReceiveMessage(message => {
    console.log("didReceiveMessage:", message);
});

//点击推送消息打开应用回调
UmengPush.didOpenMessage(message => {
    console.log("didOpenMessage:", message);
});

具体使用详情,请下载代码查看Example

##Example

git clone https://github.com/liuchungui/react-native-umeng-push.git
cd react-native-umeng-push/Example
npm install --save

##注意

  • 安卓如果获取不到deviceToken也接收不到推送,请查看友盟后台的包名是否一致,当前设备是否添加到测试设备当中

##More

  • 欢迎大家Pull Request
  • 有什么疑问,欢迎提问题
  • 觉得好的,来一个star