define(["tiny"],function(a){var b={relation:{}};return b.init=function(a){b.relation=a.relation,b.checkconnect(),b.initAjpush(),b.checkSmartUpdate()},b.checkSmartUpdate=function(){api.addEventListener({name:"smartupdatefinish"},function(a,b){api.rebootApp()})},b.checkconnect=function(){if(api.addEventListener({name:"offline"},function(a,b){return api.openFrame({name:"frm_connect",url:"widget://html/connect.html",bounces:!0,rect:{x:0,y:0,w:"auto",h:"auto"}}),!1}),"none"==api.connectType)return api.openFrame({name:"frm_connect",url:"widget://html/connect.html",bounces:!0,rect:{x:0,y:0,w:"auto",h:"auto"}}),!1;api.addEventListener({name:"online"},function(a,b){var c=api.igetPrefs("url_cn");c&&(window.location.href=c)})},b.netAudioPlay=function(a,c){var d=api.require("netAudio");return c>0&&d.play({path:a},function(d){d.complete&&(c--,b.netAudioPlay(a,c))}),!0},b.speechRecognizerRead=function(a,c){var d=api.require("speechRecognizer");return c>0&&d.read({readStr:a,speed:60,volume:100,voice:"xiaoyan",rate:16e3},function(d,e){d.status&&100==d.speakProgress&&(c--,b.speechRecognizerRead(a,c))}),!0},b.play=function(a,c,d){var e=api.igetPrefs("phonic");if(e.vibrate&&api.notification({vibrate:[3e3,3e3]}),e.voice){var f=e[a].times;f="loop"==f?100:3;1==e.voice_type?b.speechRecognizerRead(d,f):b.netAudioPlay(c,f)}return!0},b.initAjpush=function(){var a=api.require("ajpush");a.setBadge({badge:0}),a.init(function(a){a&&a.status});var c=api.igetPrefs("push_code");if(b.relation&&(!c||c&&b.relation.code&&c!=b.relation.code)){var d={};b.relation.alias&&(d.alias=b.relation.alias),b.relation.tags&&(d.tags=b.relation.tags),a.bindAliasAndTags(d,function(a,c){var d=a.statusCode;0==d?api.isetPrefs("push_code",b.relation.code):alert("同步推送信息出错："+d)})}a.setListener(function(a){var c=a.extra;try{c=JSON.parse(a.extra)}catch(a){}if("ios"==api.systemType){api.require("ajpush").setBadge({badge:0})}b.play(c.notify_type,c.resource,c.voice_text)}),api.addEventListener({name:"appintent"},function(a,b){if(a&&a.appParam.ajpush){var c=a.appParam.ajpush,d=JSON.parse(c.extra);location.href=d.url}}),api.addEventListener({name:"noticeclicked"},function(a,b){if(a&&a.value){var c=api.require("ajpush");c.setBadge({badge:0});var c=a.value,d=c.extra;location.href=d.url}})},window.cloudApp=b,b});