Tag: android

如何使用google-play-purchase-validator在应用程序和node.js服务器之间进行有效购买

我有一个应用程序,我正在testing,可以自由使用,但在应用程序购买。 我已经运行在谷歌Play商店的阿尔法,我过去使用android.test SKU,然后安装我自己的工作。 现在,当有人进行购买时,我希望应用程序能够向我的服务器传达我的服务器需要的信息,以便向Google询问应用程序购买是否合法,然后转向并妥善地logging他们的帐户,因为控制服务已完成由服务器。 到目前为止,我有这样的: 在我的节点服务器的index.js文件中,我有一个像这样的段: var Verifier = require('google-play-purchase-validator'); function validUserPurchases (receipt) { var options = { email: "#################@developer.gserviceaccount.com", key: "—–BEGIN PRIVATE madness —–END PRIVATE KEY—–\n", keyFile: "./Google Play Android Developer-##########.json" }; var verifier = new Verifier(options); verifier.verify(receipt, function cb(err, response) { if (err) { console.log("there was an error validating the receipt"); console.log(err); } […]

jpm-mobile与ReferenceError失败:cmd未定义

这里是显示的堆栈跟踪: $ /tmp/node_modules/jpm-mobile/bin/jpm-mobile init /tmp/node_modules/jpm-mobile/bin/jpm-mobile:50 if (cmd.isEmptyCommand(program)) { ^ ReferenceError: cmd is not defined at Object.<anonymous> (/tmp/node_modules/jpm-mobile/bin/jpm-mobile:50:5) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3 npm list显示安装了jpm-mobile。

如何分享Android活动之间的socket.io连接?

在socket.io Android客户端示例项目中,我们读到: IO.socket()返回一个带有默认选项的http://chat.socket.io的套接字。 请注意,该方法会caching结果,所以您可以始终从任何Activity或Fragment中为url获取同一个Socket实例。 所以我决定testing一下,因为我的服务器上打开的套接字数量不等于客户端的数量。 我用下面的服务器: var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendfile('index.html'); }); io.on('connection', function(socket){ console.log('- connect event '+socket.id); socket.on('disconnect', function () { console.log('- disconnect event from id '+socket.id); }); }); http.listen(3000, '0.0.0.0', function(){ console.log('. listening on *:3000'); }); 并开发了一个非常简单的Android应用程序,包含两个活动,每个打开socket.io连接到相同的服务器地址,并允许简单地切换活动。 我启动服务器并启动应用程序,这是我得到的输出。 . listening on *:3000 […]

Android Node.js Socket.io不能连接

我有一个Node.js服务器使用socket.io和一个Android应用程序。 我想我的应用程序连接到服务器。 (我在当地工作) 所以首先我启动服务器: 命令提示符 这是它的代码: var express = require('express'); // call express var app = express(); var http = require('http').Server(app); var io = require('socket.io')(http); var port = process.env.PORT || 1234; app.get('/',function(req,res){ res.send("Welcome to my socket"); }); io.on('connection', function (socket) { console.log('one user connected : '+socket.id); // when the client emits 'new message', this listens […]

React Native和Node服务器 – 设备上的节点服务器

我熟悉React Native,并且有一个应用程序在模拟器和设备上工作。 在这两种情况下,node.js服务器都在我的本地机器上运行,并且为了使应用程序运行,这是必需的。 我明白,对于应用程序的发布版本,我必须有一个稳定可靠的节点服务器(AWS)运行,并有我的应用程序指向。 但是,应用程序可以以某种方式与节点服务器捆绑在一起吗? 这样的应用程序可以随时离线运行。 这在iOS上可能比在Android上更难,但我想知道你的想法是什么。 谢谢!

使用Androidlogin时,Passport.js会话未设置

在我的AuthController.js中,我检查login是否成功,并在会话中设置一个哈希码: req.logIn(user, function (err) { if (err) res.send(err); var redirectTo = req.session.redirectTo ? req.session.redirectTo : '/user/show/'+user.id; delete req.session.redirectTo; bcrypt.genSalt(10, function (err, salt) { bcrypt.hash(user.email, salt, function (err, hash) { if (err) { console.log(err); } else { req.session.passport.user_type = user.type; req.session.passport.user_avatar = user.avatar; req.session.passport.email = user.email; req.session.passport.token = hash; // here session is set! also when […]

问题与mongoose时间戳记和时代转换为date()

我有一个Mongoose模式与timestamp选项设置为true。 schema = new mongoose.Schema({ … }, { timestamps: true }); 现在我有一个使用System.currentTimeMillis()获取时间戳的Android应用程序,它工作得很好,并且自UNIX纪元时间以来可以提供毫秒数。 我将这些数据发送到我的Node.js / Express服务器上,这个服务器会花费时间,只返回在特定date之后创build的文档。 // get all docs router.get('/api/seekers', function(req, res) { Seeker.find({createdAt:{ $gt: new Date(req.query.timestamp) }}, function(err, seekers) { if(err) res.send(err); else res.json(seekers); }); }); 所以我发送https://api_url.com/api/seekers?timestamp=1479431351762作为一个请求到服务器。 现在发生了一些事情: 我以毫秒为单位发送值,并得到这个错误 {"message":"Cast to date failed for value \"Invalid Date\" at path \"updatedAt\"","name":"CastError","kind":"date","value":null,"path":"updatedAt"} 经过一点调查,事实certificate,你需要秒通过Date() 。 所以, 我把值除以1000得到秒( […]

Cordova构build和gradle依赖关系

那么,这个项目就像一个魅力的工作。 更新整个堆栈的多个部分之后: NPM 节点 cordova Android的 现在,运行: cordova build 返回以下错误: FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android'. Could not resolve all dependencies for configuration ':_debugApk'. A problem occurred configuring project ':CordovaLib'. Could not resolve all dependencies for configuration ':CordovaLib:classpath'. Could not find com.android.tools.build:gradle:2.2.2. Searched in […]

Android客户端没有收到来自node.js服务器的socket.io消息

我已经使用socket.io将Android客户端连接到node.js服务器,并且能够将消息发送到服务器,但不能在客户端上接收。 对于客户端我喜欢 Log.i("MainActivity: ", "sending message"); final JSONObject sdpObj = new JSONObject(); try { sdpObj.put("id","presenter"); sdpObj.put("sdpOffer",localSdpOffer.description); } catch (JSONException e) { e.printStackTrace(); } LoginActivity.mSocket.emit("new message", sdpObj); 并在服务器上收到对象如: io.sockets.on('connection',function(socket){ socket.on('new message',function(message){ // some logic socket.emit('created',object); 那么在客户端: LoginActivity.mSocket.on("created", new Emitter.Listener() { @Override public void call(Object… args) { Log.i( TAG, "message back:received "); User user = new User(); […]

React Native – 将package.json中的自动版本名称转换为Android构build清单

目前我有一个反应原生的应用程序,我有这个问题是非常耗时更新每个版本或提交的版本。 另外,我还有Sentry,因此每次构build时,都会得到相同的版本,所以一些崩溃很难确定它们来自哪里。 最后,手动更新版本容易出错。 我怎样才能设置我的构build生成一个自动版本,每次我build立和忘记所有这个手动任务?