我正在寻找一种使用离子框架进行语音识别的方法.我想在ios和android设备上运行一个应用程序.目前我在ios和android中都提供了一个Web视图,并且有一个共同的代码库.我想要包含语音识别功能并获取语音输出.
我很难获得推送通知(使用ngCordova插件).我完全遵循了网站上记录的示例代码:http://ngcordova.com/docs/plugins/pushNotifications/
(唯一的区别是我没有设备监听器,相反,我的代码在ionicPlatform.ready监听器中.)
这是我的代码:
angular.module('myApp', ['ionic', 'ngCordova'])
.run(function($ionicPlatform, $rootScope, $state, $cordovaPush) {
$ionicPlatform.ready(function() {
var config = {
"senderID": "myID100001000"
};
$cordovaPush.register(config).then(function(result) {
alert(result);
}, function(err) {
alert(err);
})
});
$rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
switch(notification.event) {
case 'registered':
if (notification.regid.length > 0 ) {
alert('registration ID = ' + notification.regid);
}
break;
default:
alert('An unknown GCM event has occurred');
break;
}
});
})
Run Code Online (Sandbox Code Playgroud)
当我的应用程序启动时,我会收到"确定"警告,因此我知道它成功通过了$ cordovaPush.register调用.但是,我希望在之后获得"注册"通知事件,但我从未收到通知.
任何帮助,将不胜感激.
我刚开始涉足Cordova/Ionic,用HTML5/js制作Android/iOS应用程序,到目前为止,我已经有时候使用示例/教程应用程序,但不是每次都有.
我正在使用Windows,我正在尝试为Android构建我的项目.
经过几次尝试,我不再能够构建我的应用程序,甚至完全"空白"模板应用程序,我根本没有改变.我尝试通过Cordova创建应用程序
cordova create hello com.example.hello HelloWorld
cd hello
cordova build android
Run Code Online (Sandbox Code Playgroud)
或离子
ionic start test sidemenu
cd start
ionic build android
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我都得到同样的错误:
Running command: C:\Users\nthissen\Dropbox\Mobile\Projects\hello\platforms\andro
id\cordova\build.bat
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
ERROR building one of the platforms: Error: C:\Users\nthissen\Dropbox\Mobile\Pro
jects\hello\platforms\android\cordova\build.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Run Code Online (Sandbox Code Playgroud)
是的,我确实安装了Android …
我开始了一个基于sidemenu模板的离子项目.我正在尝试更改侧边菜单中每个元素的背景颜色(我希望每个项目都有不同的颜色).
我试图添加一个离子颜色类:
<ion-side-menu side="left">
<ion-header-bar class="bar-stable">
<h1 class="title">Left</h1>
</ion-header-bar>
<ion-content>
<ion-list>
<ion-item class="positive-bg" nav-clear menu-close ng-click="login()">
Login
</ion-item>
<ion-item class="calm-bg" nav-clear menu-close href="#/app/search">
Search
</ion-item>
<ion-item class="assertive-bg" nav-clear menu-close href="#/app/browse">
Browse
</ion-item>
<ion-item nav-clear menu-close class="balanced-bg" href="#/app/playlists">
Playlists
</ion-item>
</ion-list>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
它适用于Login元素,但不适用于其他元素.删除其他元素的href属性有效...如何获得背景颜色和href元素?
当运行离子服务时,我看到:
Gulp startup tasks: [ 'sass', 'watch' ]
Running dev server: http://localhost:8100
Running live reload server: http://localhost:35729
Watching : [ 'www/**/*', '!www/lib/**/*' ]
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit
Run Code Online (Sandbox Code Playgroud)
这意味着我无法从浏览器访问该应用程序,因为它只侦听localhost.如何将localhost更改为实际的服务器IP?
谢谢
我正在使用具有命令行界面的Ionic.我想创建一个有助于执行某些命令的小型Mac应用程序.
在终端我cd Users/me/Desktop/Repos/ionic-project/myApp
改变之后我会例如ionic run
NSTask *task = [[NSTask alloc]init];
task.launchPath = @"/bin/bash";
task.currentDirectoryPath = @"cd Users/me/Desktop/Repos/ionic-tryouts/myApp";
task.arguments = @[@"ionic run"];
[task launch];
Run Code Online (Sandbox Code Playgroud)
但这给了我'工作目录不存在'.我已经在SO上阅读了相当多的主题.我的错是什么?
编辑:
感谢Christik的详细解答.我现在有这个代码:
NSTask *task = [[NSTask alloc]init];
task.launchPath = @"/usr/local/bin/ionic";
task.currentDirectoryPath = @"/Users/me/ionic-tryouts/myApp";
task.arguments = @[@"run"];
[task launch];
Run Code Online (Sandbox Code Playgroud)
现在我收到以下错误:env:node : No such file or directory. 我想这来自一个问题,即找不到node.js(离子是在节点之上构建的).我发现了这个问题 - 缺少正确名称的符号链接可能是原因.但是为节点设置符号链接没有帮助.有任何想法吗?
编辑2:我给了Christik正确的答案,即使我最终无法让它工作.我还在调查.也许这是节点安装错了.
编辑方式3:我看到一些帖子提到它可能会更好,如果自己的homebrew重新安装节点,因为自制软件安装它没有sudo.简短评论:没有帮助
我用Ionic Popover设置了一个基本的例子.但是,当我打开弹出窗口时,不透明度保持为零,从而阻止弹出窗口显示.我知道openPopover调用该方法是因为我opened在Web控制台中收到了控制台日志.如果我从控制台中删除opacity属性,则会显示弹出窗口.
我的控制器..
angular.module('search')
.controller('SearchResultsController', searchResultsController)
searchResultsController.$inject = ['$ionicPopover', '$scope'];
function searchResultsController($ionicPopover, $scope) {
var vm = this;
vm.openPopover = openPopover;
activate();
function activate( ) {
$ionicPopover.fromTemplateUrl('/templates/search/filter-popover.html', {
scope: $scope
}).then(function(popover) {
console.log(popover)
vm.popover = popover;
});
}
function openPopover( $event ) {
console.log("opened")
vm.popover.show($event);
}
}
Run Code Online (Sandbox Code Playgroud)
我的观点页......
<ion-view hide-nav-bar="true">
<signed-in-header></signed-in-header>
<ion-content class="padding has-header">
<div class="row">
<div class="col col-75 text-left">
<div>4 RESULTS FOR "263355"</div>
</div>
<div class="col col-25 text-right">
<div ng-click="searchResults.openPopover()">
<i class="icon ion-arrow-down-b"></i>
Filter
</div> …Run Code Online (Sandbox Code Playgroud) 我已经在我的Windows7 pc中下载并安装了nodejs(安装文件node-v0.12.5-x64).
还通过命令安装ionic:npm install -g ionic cordova
所有离子命令都给出相同的错误,即undefined:1.
在命令提示符下,它如下所示:
E:\programs>ionic -v
undefined:1
SyntaxError: Unexpected token
Run Code Online (Sandbox Code Playgroud)
经过多次安装和卸载后,我无法解决.
请帮忙.
我在本地目录中创建了简单的应用程序,该应用程序名称是Ionic-Chat-master
我怎么能这个到apk文件?
我使用git尝试了以下命令,但没有为我工作
npm install -g cordova
cordova build --release android
Run Code Online (Sandbox Code Playgroud)
这会显示错误(sh.exe": cordova: command not found).
寻找更新的解决方案,运行使用Cordova 5.x的最新离子1.1.0版本.试图能够浏览Chrome中的网站,并使用网络意图将该网址发送到我的离子Android应用程序.我的应用程序编译和运行,但是当我尝试使用份额从功能铬(或任何其他应用程序),然后选择我的应用程序分享给我的应用程序崩溃.
我首先尝试使用插件:
离子插件添加https://github.com/Initsogar/cordova-webintent
然后删除了插件,我也尝试了一个最近更新的fork:
离子插件添加https://github.com/fluentstream/cordova-webintent
在我的app.js文件中,我输入以下代码:
.run(function($ionicPlatform, $rootScope, $ionicHistory, $state) {
$ionicPlatform.ready(function() {
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT,
function(url) {
incomingURL = url;
//alert(incomingURL);
console.log(incomingURL);
}, function() {
incomingURL = false;
//alert("no url");
console.log("no url");
});
});
})
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
.run(function($ionicPlatform, $rootScope, $ionicHistory, $state) {
$ionicPlatform.ready(function() {
window.plugins.webintent.getUri(function(url) {
if(url !== "") {
alert(url);//url is the url the intent was launched with
}
});
});
})
Run Code Online (Sandbox Code Playgroud)
在文件config.xml中我会放:
<plugin name="WebIntent" value="com.borismus.webintent.WebIntent"/>
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest.xml中我会手动输入:
<activity android:name="ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" …Run Code Online (Sandbox Code Playgroud)