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

@beesight/rct-baidupush

v1.0.6

Published

baidu push with react native

Downloads

2

Readme

rct-baidupush

Getting started

$ npm install @beesight/rct-baidupush --save

Manual link

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules@beesight/rct-baidupush and add RNBssBaidupush.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNBssBaidupush.a to your project's Build PhasesLink Binary With Libraries
  4. In XCode, in the project navigator, select your project.
    • Go the General tab ➜ Linked Frameworks and Libraries+ button ➜ Add Othernode_modules/@beesight/rct-baidupush/ios/normalversion ➜ choose libBPush.a .
    • Look for Header Search Paths and make sure it contains $(SRCROOT)/../node_modules/@beesight/rct-baidupush/ios and Libraries Search Paths contains $(SRCROOT)/../node_modules/@beesight/rct-baidupush/ios/normalversion
    • Mark linker in Libraries Search Paths as recursive .
  5. Open up your AppDelegate.m
  • Add #import "RNBssBaidupush.h"
  • Add #import <UserNotifications/UserNotifications.h>
  • Register
    • Replace your_api_key in your_api_key
    • Choose mode you want: BPushModeDevelopment or BPushModeProduction in baidu_Mode
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {
   .....
     [RNBssBaidupush registerBaidu:launchOptions application:application apiKey:@"your_api_key" baiduMode:@"baidu_Mode"];
      UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
       center.delegate = self;
     return YES;
    }
    
    //This method is triggered when the user clicks on the notification, the application is in the foreground or the background is turned on and the application is in the background.
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
    {
      NSLog(@"Receive mess:%@",userInfo);
      [RNBssBaidupush application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    
    }
    
    // In the iOS8, you also need to add this method. Sign up for push services with the new API
    - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
    {
      [application registerForRemoteNotifications];
    
    }
    
    //Register deviceToken
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    {
    
      [RNBssBaidupush application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    
    }
    
    //When the DeviceToken acquisition fails, the system will call back this method.
    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
      [RNBssBaidupush application:application didFailToRegisterForRemoteNotificationsWithError:error];
    }
    
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    {
      NSLog(@"userInfo: %@",userInfo);
      if (application.applicationState == UIApplicationStateActive || application.applicationState == UIApplicationStateBackground) {
        NSLog(@"acitve or background");
        /*UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error display content" message:@"Error connecting to server, no local database" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:_alertController animated:YES completion:nil];*/
      }
    }
    
    // Show notification when app is foreground
    -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
    {
      completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
      NSLog(@"Userinfo %@",notification.request.content.userInfo);
    }

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.rct_baidupush.RNBssBaidupushPackage; to the imports at the top of the file
  • Add new RNBssBaidupushPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':rct-baidupush'
    project(':rct-baidupush').projectDir = new File(rootProject.projectDir, 	'../node_modules/@beesight/rct-baidupush/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

      compile project(':rct-baidupush')
  3. Open up android/app/src/main/AndroidManifest.xml add permissions

    <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
     
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="baidu.push.permission.WRITE_PUSHINFOPROVIDER.com.eflink.mobile"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />

    Add permissions to access push notification (replace your app package):

    <permission
           android:name="baidu.push.permission.WRITE_PUSHINFOPROVIDER.your_app_package"
           android:protectionLevel="normal"> 
     </permission>

    Under <application> (replace your app package)

     <provider
            android:name="com.baidu.android.pushservice.PushInfoProvider"
            android:authorities="com.eflink.mobile.bdpush"
            android:writePermission="baidu.push.permission.WRITE_PUSHINFOPROVIDER.your_app_package"
            android:protectionLevel = "signature"
            android:exported="true" />
     <meta-data
               android:name="api_key"
               android:value="enter_your_api_key" />

Usage

      import RNBssBaidupush from '@beesight/rct-baidupush';
      // when receive a message
      RNBssBaidupush.monitorReceiveMessage((message) => {
         console.log('monitorReceiveMessage=' + JSON.stringify(message))
       })
       
       // when click on message
       RNBssBaidupush.monitorBackstageOpenMessage((message) => {
         console.log('monitorClickMessage=' + JSON.stringify(message))
       })
       
       // get ChannelId
       RNBssBaidupush.getChannelId().then((ChannelId) => {
         if (!isNil(ChannelId)) { this.setState({tokenId: ChannelId}) }
         console.log('ChannelId=' + ChannelId)
       })

Environment

  • react-native: 0.53.0
  • node: 10.0.0
  • npm: 5.6.0
  • baidu-push:
    • Android 5.9.0
    • IOS 1.5.4
  • Device test:
    • Android 6.0
    • IOS 12.0