1.0.69 • Published 2 years ago

@aks-dev/upush v1.0.69

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

安装

$ npm install @aks-dev/upush --save

or

$ yarn add @aks-dev/upush

配置

android


  • MainApplication.onCreate()
UMCommonHelper.getInstance().preInit(
        this,
        "6285xxxxxd55d",
        "27b961axxxxxx54cf976");

UMPushHelper.getInstance().preSet(
        this,
        null
);

离线推送配置

  • buildscript.repositories
maven { url 'https://developer.huawei.com/repo/' }
  • buildscript.dependencies
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
  • allprojects.repositories
maven { url 'https://developer.huawei.com/repo/' }
maven { url 'https://repo1.maven.org/maven2/' }
  • agconnect-services.json
  • AndroidManifest.xml
<meta-data
    android:name="com.huawei.hms.client.appid"
    android:value="appid=xxxx" />
<meta-data
    android:name="com.vivo.push.api_key"
    android:value="xxxx" />
<meta-data
    android:name="com.vivo.push.app_id"
    android:value="xxxx" />

ios


#import "UMPushHelper.h"
#import "UMCommonHelper.h"

eg:

  • AppDelegate.application...didFinishLaunchingWithOptions()
[[UMCommonHelper share] setAppKey:@"xxx"];
[[UMPushHelper share] registerForRemoteNotificationsWithLaunchOptions:launchOptions];

other functions ...

//==================push============================================

//iOS10以下使用这两个方法接收通知
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [[UMPushHelper share] application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];

}

//iOS10新增:处理前台收到通知的代理方法
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
    [[UMPushHelper share] userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
}

//iOS10新增:处理后台点击通知的代理方法
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{
    [[UMPushHelper share] userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

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

//==================push============================================

js


  • import * as upush from '@aks-dev/upush'
函数作用
initsdk冷启动,返回deviceToken
addListener监听通知事件
setBadgeCount设置角标

eg:

React.useEffect(() => {
    let subscription = upush.addEventListener((event) => {
        //todo:
    })

    return ()=>{
        subscription.remove()
    }
}, [])
1.0.69

2 years ago

1.0.66

2 years ago

1.0.65

2 years ago

1.0.64

2 years ago

1.0.67

2 years ago

1.0.63

2 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.40

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago