UNPKG

crn-cli

Version:

The Ctrip React Native CLI Tools

1 lines 3.83 kB
__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),f=u.Alert,h=u.PushNotificationIOS,v=u.StyleSheet,p=u.Text,E=u.TouchableHighlight,b=u.View,N=(function(u){function f(){return t(this,f),o(this,s(f).apply(this,arguments))}return l(f,u),n(f,[{key:"render",value:function(){return c.createElement(E,{underlayColor:'white',style:_.button,onPress:this.props.onPress},c.createElement(p,{style:_.buttonLabel},this.props.label))}}]),f})(c.Component),y=(function(u){function v(){return t(this,v),o(this,s(v).apply(this,arguments))}return l(v,u),n(v,[{key:"UNSAFE_componentWillMount",value:function(){h.addEventListener('register',this._onRegistered),h.addEventListener('registrationError',this._onRegistrationError),h.addEventListener('notification',this._onRemoteNotification),h.addEventListener('localNotification',this._onLocalNotification),h.requestPermissions()}},{key:"componentWillUnmount",value:function(){h.removeEventListener('register',this._onRegistered),h.removeEventListener('registrationError',this._onRegistrationError),h.removeEventListener('notification',this._onRemoteNotification),h.removeEventListener('localNotification',this._onLocalNotification)}},{key:"render",value:function(){return c.createElement(b,null,c.createElement(N,{onPress:this._sendNotification,label:"Send fake notification"}),c.createElement(N,{onPress:this._sendLocalNotification,label:"Send fake local notification"}))}},{key:"_sendNotification",value:function(){r(d[7]).emit('remoteNotificationReceived',{remote:!0,aps:{alert:'Sample notification',badge:'+1',sound:'default',category:'REACT_NATIVE','content-available':1}})}},{key:"_sendLocalNotification",value:function(){r(d[7]).emit('localNotificationReceived',{aps:{alert:'Sample local notification',badge:'+1',sound:'default',category:'REACT_NATIVE'}})}},{key:"_onRegistered",value:function(t){f.alert('Registered For Remote Push',"Device Token: "+t,[{text:'Dismiss',onPress:null}])}},{key:"_onRegistrationError",value:function(t){f.alert('Failed To Register For Remote Push',"Error ("+t.code+"): "+t.message,[{text:'Dismiss',onPress:null}])}},{key:"_onRemoteNotification",value:function(t){var n="Message: "+t.getMessage()+";\n\n badge: "+t.getBadgeCount()+";\n\n sound: "+t.getSound()+";\n\n category: "+t.getCategory()+";\n\n content-available: "+t.getContentAvailable()+".";f.alert('Push Notification Received',n,[{text:'Dismiss',onPress:null}])}},{key:"_onLocalNotification",value:function(t){f.alert('Local Notification Received','Alert message: '+t.getMessage(),[{text:'Dismiss',onPress:null}])}}]),v})(c.Component),P=(function(u){function f(n){var l;return t(this,f),(l=o(this,s(f).call(this,n))).state={permissions:null},l}return l(f,u),n(f,[{key:"render",value:function(){return c.createElement(b,null,c.createElement(N,{onPress:this._showPermissions.bind(this),label:"Show enabled permissions"}),c.createElement(p,null,JSON.stringify(this.state.permissions)))}},{key:"_showPermissions",value:function(){var t=this;h.checkPermissions(function(n){t.setState({permissions:n})})}}]),f})(c.Component),_=v.create({button:{padding:10,alignItems:'center',justifyContent:'center'},buttonLabel:{color:'blue'}});e.title='PushNotificationIOS',e.description='Apple PushNotification and badge value',e.examples=[{title:'Badge Number',render:function(){return c.createElement(b,null,c.createElement(N,{onPress:function(){return h.setApplicationIconBadgeNumber(42)},label:"Set app's icon badge to 42"}),c.createElement(N,{onPress:function(){return h.setApplicationIconBadgeNumber(0)},label:"Clear app's icon badge"}))}},{title:'Push Notifications',render:function(){return c.createElement(y,null)}},{title:'Notifications Permissions',render:function(){return c.createElement(P,null)}}]},666786,[3,4,5,8,9,11,15,43]);