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

v0.0.6

Published

集成各个厂商的推送

Downloads

127

Readme

react-native-dux-push

Getting started

$ yarn add react-native-dux-push @react-native-community/push-notification-ios

Usage

import DuxPush from 'react-native-dux-push';

// 用户同意协议之后初始化
DuxPush.init('', '', disable);

//example    禁用oppo推送
DuxPush.init('', '', { oppo: true} );

//本地通知
DuxPush.notify(title, body)

// 设置别名
DuxPush.setAlias(alias)

// 删除别名
DuxPush.unsetAlias(alias)

// 设置标签
DuxPush.setTag(tag)

// 删除标签绑定
DuxPush.unsetTag(tag)


// 监听通知消息,oppo和vivo不支持
DuxPush.addEventListener('duxpush_notify', (res) => {
    console.log("rnduxpush", res)
});

// 监听通知栏点击
DuxPush.addEventListener('duxpush_click', (res) => {
    console.log("rnduxpush", res)
});

// ios,通过通知栏启动应用
DuxPush.getInitialNotification((res) => {
    alert(JSON.stringify(res))
});

华为

https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-config-agc-0000001050170137

  • 华为后台创建项目与应用
  • 签名校验SHA1256
  • 开通推送服务
// build.gradle
buildscript {
    repositories {
        google()
        // 配置HMS Core SDK的Maven仓地址。
        maven {url 'https://developer.huawei.com/repo/'}
    }
}

<!--AndroidManifest.xml-->
<meta-data
    android:name="com.huawei.hms.client.appid"
    android:value="appId"/>

vivo

<!--AndroidManifest.xml-->

<meta-data
    android:name="com.vivo.push.api_key"
    android:value="xxxxxxxx"/>

<meta-data
    android:name="com.vivo.push.app_id"
    android:value="xxxx"/>

OPPO

<!--AndroidManifest.xml-->
<meta-data
  android:name="com.oppo.push.app_key"
  android:value="xxx"/>
<meta-data
  android:name="com.oppo.push.app_secret"
  android:value="xxx"/>

小米

ANDROID

<!--AndroidManifest.xml-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE"/> 
<permission android:name="com.xiaomi.mipushdemo.permission.MIPUSH_RECEIVE"
android:protectionLevel="signature" /> <!--这里com.xiaomi.mipushdemo改成app的包名-->
<uses-permission android:name="com.xiaomi.mipushdemo.permission.MIPUSH_RECEIVE" /><!--这里com.xiaomi.mipushdemo改成app的包名-->


<meta-data
    android:name="com.xm.push.appid"
    android:value="\xxxxxxxx"/>
<meta-data
    android:name="com.xm.push.appkey"
    android:value="\xxxxxxxx"/>

IOS

  • targetCapabilities选项卡添加Push Notifications

  • Build Settings 中的 Other Linker Flags 中增加 -ObjC

  • 在AppDelegate.h中添加

#import <UserNotifications/UserNotifications.h>

@interface AppDelegate : EXAppDelegateWrapper <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

主要是添加 UNUserNotificationCenterDelegate

  • 在AppDelegate.m中添加
...
#import <React/RCTLinkingManager.h>
#import <RNDuxPush.h>

...
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
[RNDuxPush application:application didFinishLaunchingWithOptions:launchOptions];
...

...

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{

  [RNDuxPush application:application didRegisterUserNotificationSettings:notificationSettings];

}


- (void)application:(UIApplication *)app
        didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
  NSLog(@"推送注册失败:%@", err);
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [RNDuxPush application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];

}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
{
  [RNDuxPush application:application didReceiveRemoteNotification:notification];

}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNDuxPush application:application didReceiveLocalNotification:notification];

}

// ios 10
// 应用在前台收到通知
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  [RNDuxPush userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
}

// 点击通知进入应用
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
  [RNDuxPush userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
  completionHandler();
}

//#define __IPHONE_10_0    100000
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
  //6.3的新的API调用,是为了兼容国外平台(例如:新版facebookSDK,VK等)的调用[如果用6.2的api调用会没有回调],对国内平台没有影响。
  
    return [RCTLinkingManager application:app openURL:url options:options];
}


- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable restorableObjects))restorationHandler {
  
    return [RCTLinkingManager application:application
    continueUserActivity:userActivity
                       restorationHandler:restorationHandler];
}