
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
react-native-aliyun-onesdk
Advanced tools
#install npm install react-native-aliyun-onesdk --save
#usage
react-native link react-native-aliyun-onesdk
#configuration :
ios: https://help.aliyun.com/document_detail/30072.html
android: https://help.aliyun.com/document_detail/30064.html
##ios
mkdir yourProject/ios/OneSDK
put the aliyun frameworks to the dir
add com.alibaba.app.appkey/com.alibaba.app.appsecret to your info.plist
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[self initCloudPush];
...
}
- (void)initCloudPush {
// SDK初始化
NSString *appKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"com.alibaba.app.appkey"];
NSString *appSecret = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"com.alibaba.app.appsecret"];
[CloudPushSDK asyncInit:appKey appSecret:appSecret callback:^(CloudPushCallbackResult *res) {
if (res.success) {
} else {
}
}];
}
#pragma mark Notification Open
/*
* App处于启动状态时,通知打开回调
*/
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo {
NSLog(@"Receive one notification.");
// 取得APNS通知内容
NSDictionary *aps = [userInfo valueForKey:@"aps"];
// 内容
NSString *content = [aps valueForKey:@"alert"];
// badge数量
NSInteger badge = [[aps valueForKey:@"badge"] integerValue]+1;
// 播放声音
NSString *sound = [aps valueForKey:@"sound"];
// 取得Extras字段内容
NSString *Extras = [userInfo valueForKey:@"Extras"]; //服务端中Extras字段,key是自己定义的
NSLog(@"content = [%@], badge = [%ld], sound = [%@], Extras = [%@]", content, (long)badge, sound, Extras);
// iOS badge 清0
// application.applicationIconBadgeNumber = badge+1;
// 通知打开回执上报
// application.applicationIconBadgeNumber = application.applicationIconBadgeNumber+1;
[AliPushManager didReceiveRemoteNotification:userInfo];
}
// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[AliPushManager didRegisterUserNotificationSettings:notificationSettings];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"Upload deviceToken to CloudPush server.deviceToken:%@",deviceToken);
[AliPushManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
##android
@Override
public void onCreate() {
super.onCreate();
...
initCloudChannel(this);
}
/**
* 初始化云推送通道
*
* @param applicationContext
*/
private void initCloudChannel(Context applicationContext) {
PushServiceFactory.init(applicationContext);
CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.register(applicationContext, new CommonCallback() {
@Override
public void onSuccess(String response) {
Log.d(TAG, "init cloudchannel success");
}
@Override
public void onFailed(String errorCode, String errorMessage) {
Log.d(TAG, "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage);
}
});
//注册方法会自动判断是否支持小米系统推送,如不支持会跳过注册。
// MiPushRegister.register(applicationContext, "2882303761517489550", "5201748990550");
//注册方法会自动判断是否支持华为系统推送,如不支持会跳过注册。
// HuaWeiRegister.register(applicationContext);
}
##js
import AliPush from 'react-native-aliyun-onesdk';
AliPush.getInitialNotification().then((notification)=> {});
AliPush.requestPermissions().then((deviceId)=> {}, ()=> {});
AliPush.on('remoteNotificationReceived', (notification)=> {
//ios 在前台运行时 同样触发该方法,此时没有提示框,
});
#available ##push remoteNotification bindAccount unbindAccount
FAQs
React Native Aliyun OneSDK(notification)
The npm package react-native-aliyun-onesdk receives a total of 18 weekly downloads. As such, react-native-aliyun-onesdk popularity was classified as not popular.
We found that react-native-aliyun-onesdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.