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

@opendt/react-native-ali-push

v1.0.0

Published

react-native wrapper of Ali Push SDK, support both iOS and Android.

Downloads

2

Readme

React Native Ali Push

react-native wrapper of Ali Push SDK, support both iOS and Android.

Note, this library only support react-native 0.60+

Installation

Install library via npm:

npm install --save @opendt/react-native-ali-push

Additional steps

  • Android
  1. add aliyun maven repository to project's build.gradle file:
       allprojects {
           repositories {
    +          maven {
    +              // Aliyun repositories
    +              url 'http://maven.aliyun.com/nexus/content/repositories/releases/'
    +          }
           }
       }
  2. specify your appKey and appSecret in AndroidManifest.xml:
       <application android:name="*****">
    +    <meta-data android:name="com.alibaba.app.appkey" android:value="PUSH_APP_KEY"/>
    +    <meta-data android:name="com.alibaba.app.appsecret" android:value="PUSH_APP_SECRET"/>
       </application>
  3. update your MainApplication.java file:
    +  import xin.dayukeji.rn.alipush.DTAliPushManager;
       
       public class MainApplication extends Application implements ReactApplication {
           @Override
           public void onCreate() {
               super.onCreate();
               SoLoader.init(this, /* native exopackage */ false);
    +          DTAliPushManager.initCloudChannel(this);
           }
        }
  4. update your MainActivity.java file(or wherever you create an instance of ReactActivityDelegate):
    +  import xin.dayukeji.rn.alipush.DTAliPushManager;
       
       public class MainActivity extends ReactActivity {
    +      @Override
    +      protected ReactActivityDelegate createReactActivityDelegate() {
    +          return new ReactActivityDelegate(this, getMainComponentName()) {
    +              @Override
    +                  protected Bundle getLaunchOptions() {
    +                      Bundle initialProps = new Bundle();
    +                      initialProps.putBundle("notification", DTAliPushManager.extractPushData(getIntent()));
    +                      return initialProps;
    +                  }
    +              };
    +          }
    +      }
       }
  • iOS
  1. add Aliyun's Pod repository to your Podfile:
    source 'https://github.com/aliyun/aliyun-specs.git'
    or, you can add global repo, run:
    pod repo add aliyum https://github.com/aliyun/aliyun-specs.git master
    then you need to complete the linking on iOS, run:
    cd ios && pod install
  2. update your AppDelegate.m file:
    +  #import "DTAliPush.h"
       - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...
    +    [[DTAliPush sharedInstance] initWithKey:@"PUSH_APP_KEY" appSecret:@"PUSH_APP_SECRET" callback:nil];
    +    [[DTAliPush sharedInstance] registerAPNS:application];
    +    [[DTAliPush sharedInstance] handleNotification:launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];
         return YES;
       }
       
    +  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    +    [[DTAliPush sharedInstance] registerDeviceToken:deviceToken withCallback:nil];
    +  }
       
    +  // for iOS < 10
    +  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    +    [[DTAliPush sharedInstance] handleNotification:userInfo];
    +  }
  3. enable Push Notifications capability in Xcode, and config push certifications in Aliyun Console, see help doc

Usage

  1. import package in your js files

    import AliPush from '@opendt/react-native-ali-push';
  2. AliPush.subscribe(event: string, callback: Function)
    subscribe to SDK event. available event are:

    AliPush.subscribe(AliPush.EVT_NOTIFICATION, notification => {
        console.log('new notification', notification);
    });
    • AliPush.EVT_NOTIFICATION: event indicated that new notification received.
    • AliPush.EVT_NOTIFICATION_OPENED: user click the notification to open it.
    • AliPush.EVT_NOTIFICATION_REMOVE: user dismissed the notification.
  3. AliPush.bindAccount(uid: string): Promise
    bind account to Ali Push service

  4. AliPush.unbindAccount(uid: string): Promise
    unbind account, if you want to bind to another account, you can directly call bindAccount(anotherUid).

  5. AliPush.binfTag(tags: Array<string>, target, alias: string): Promise
    bind tags to specified target, where target must be one of TARGET_ACCOUNT, TARGET_DEVICE, TARGET_ALIAS. if target is TARGET_ALIAS, third param alias must be specified.

  6. AliPush.unbindTag(tags: Array<string>, target, alias: string): Promise
    unbind tags from specified target.