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-aliyun-onesdk

v0.2.3

Published

React Native Aliyun OneSDK(notification)

Downloads

18

Readme

react-native-aliyun-onesdk

#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