Tag: objective c

更改UIImage类发送到iOS中的node.js服务器?

我正在创build一个聊天应用程序。 现在我想发送UIImage到服务器的JSONstring,以便其他用户可以接收image.I使用socket.io所以我必须发送事件与数据(JSONstring)。 问题 – 当我尝试将UIImage转换为NSData并将其转换为JSON时,会给出错误“JSON写入(NSConcreteMutableData)中的无效types” 。 什么是将UIImage发送到服务器的正确方法? 码 NSData *imgData = UIImageJPEGRepresentation(image, .2); NSString * imageString =[[NSString alloc]initWithBytes:[imageData bytes] length:[imageData length] encoding:NSASCIIStringEncoding]; 也试过了 NSString * imageString =[[NSString alloc]initWithData :imgData encoding:NSUTF8StringEncoding]; 将数据转换为字典: NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:imgData options:NSJSONReadingAllowFragments error:&error]; 任何帮助,将不胜感激。

{“code”:1,“message”:“Session ID unknown”}将用户连接到socket.io进行第一次尝试

我正在使用objective-c中的socket.io开发聊天应用程序。 我正面临着丢失离线消息的问题。 该场景是当我有几个队列中的离线消息,当客户端(iOS应用程序)连接。 最初它直接断开“会话ID未知”。 以下是使用套接字连接的代码 NSURL* url = [[NSURL alloc] initWithString:@"MYURL"]; self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @NO, @"reconnectAttempts" : @50, @"reconnects" : @YES, @"forcePolling": @YES}]; if (![self.socket.engine connected]) { [self.socket connectWithTimeoutAfter:20000 withHandler:^{ NSLog(@"Socket Conencted"); }]; } [self.socket off:@"disconnect"]; [self.socket off:@"error"]; [self.socket off:@"add user"]; [self.socket off:@"private message"]; [self.socket off:@"connect"]; [self.socket off:@"startChat"]; [self.socket off:@"delivered"]; [self.socket off:@"user […]

无法在xcode错误条目上运行react-native项目“:CFBundleIdentifier”,不存在

我更新react-native 。我使用https://facebook.github.io/react-native/docs/getting-started.html此链接configuration为移动开发react-native和尝试运行ios项目与命令react-native run-ios但我无法运行该项目。 我已经看到了很多关于我的问题的链接,并尝试了许多解决scheme,如link1 link2 React Native Build命令失败:PhaseScriptExecution …(domain = NSPOSIXErrorDomain,code = 2) 在提供的path中找不到应用程序束…“:CFBundleIdentifier”,不存在 打印:条目“:CFBundleIdentifier”不存在 日志是 ** BUILD FAILED ** The following build commands failed: CompileC /Users/macbook/feed/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/third-party.build/Objects-normal/x86_64/Conv.o /Users/macbook/feed/node_modules/react-native/third-party/folly-2016.09.26.00/folly/Conv.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler CompileC /Users/macbook/feed/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/third-party.build/Objects-normal/x86_64/StringBase.o /Users/macbook/feed/node_modules/react-native/third-party/folly-2016.09.26.00/folly/StringBase.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (2 failures) Installing build/Build/Products/Debug-iphonesimulator/feed.app An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2): Failed to install […]

适用于Node.js或Objective-C的Google Drive实时API SDK?

适用于Node.js或Objective-C的Drive Realtime API库的状态如何? 我正确的是唯一支持的用例是浏览器中的客户端(由文档判断)? 我花了两天的时间试图让它与Mac应用程序,没有成功。 我正在问具体的实时API,因为我有Drive APIs正常工作。 感谢一些反馈,我真的无法find自己的东西。

Instagram的API – 无法获得接受跟踪请求的私人用户的媒体

我在应用程序中使用Instagram API来查看其他Instagram的照片。 如果一个Instagram账号是私人的,那么这些照片就不能被看到,这是有道理的。 但是,如果这个私人Instagram已经接受了请求他们媒体的用户(访问令牌)的请求,那么这个媒体应该是可用的(对吗?),但是在提出请求时我仍然收到错误。 我正在使用这个请求端点: https://api.instagram.com/v1/users/PRIVATE_PROFILE_ID/media/recent/ ?access_token=ACCESS_TOKEN_OF_USER_THAT_IS_ALLOWED_TO_FOLLOW_PRIVATE_PROFILE 不pipe请求的访问令牌是否具有遵循该configuration文件的权限,API是不是授予访问私人configuration文件的简单情况? 这里也提到了一个类似的问题,但没有真正回答

Objective-C序列化字典与节点js服务器

我有一个序列化的NSDictionary (实际上,它是一个inapp购买收据),我发送到node.js服务器: { "key 1" = "val 1"; "key 2" = "val 2"; } 我想在服务器端反序列化,所以这就是我迄今为止所做的: var jsonStr = dictStr.replace(/"\s*=\s*"/g, "\":\"").replace(/";\s/g,"\",").replace(/,\s*}/,"}"); var obj = JSON.parse(jsonStr); 上面的代码工作得很好,但当然我担心如果我考虑到所有可能的情况。 这就是为什么我更喜欢有一个真正的parsing器obj-c NSDictionary格式。 可能有人可以推荐我一个?

域= NSPOSIXErrorDomain代码= 61

我试图连接客户端(iOS应用程序)和服务器(Node.js)之间使用SocketRocket和ws如下所示。 的iOS(SocketRocket): NSURL *url = [NSURL urlWithString:@"ws://localhost:8080"]; SRWebSocket *_socket = [SRWebSocket alloc] initWithURLRequest:[NSURLRequest requestWithURL:url]; _socket.delegate = self; [_socket open]; /* SRWebSocketDelegate */ -(void)webSocketDidOpen:(SRWebSocket*)webSocket{ [webSocket send:@"something"]; } -(void)webSocket:(SRWebSocket*)webSocket didReceiveMessage:(id)message{ NSLog(@"didReceiveMessage: %@",[message description]); } -(void)webSocket:(SRWebSocket*)webSocket didFailWithError:(NSError*)error{ NSLog(@"the Error: %@",error); } Node.js的(WS): var WebSocketServer = require('ws').Server var wss = new WebSocketServer({ host:'localhost', port:8080 }); wss.on('connection',function(ws){ ws.on('message',function(message){ console.log('received: %s', […]

试图从iPhone连接到node.js和socket.io 0.7.2

正如问题所说,我试图从iphone / ipad上运行的应用程序连接到socket.io服务器。 在另一个Q我find了链接来实现这一点的帮助 https://github.com/fpotter/socketio-cocoa … buuuut 它不工作了(socket.io 0.7.2)。 我得到的错误消息是: socket.io warn – unknown transport: "undefined" 客户 Connection failed with error: The operation couldn't be completed. (WebSocketErrorDomain error 1.) 降级socket.io到版本0.6.17的作品,但我仍然想尝试使用最新版本启动和运行。 也许有人可以指出我正确的方向什么改变w / 0.7.2所以我可以修复socketiococoa类(或这些https://github.com/erichocean/cocoa-websocket – 因为socketiococoa依赖于他们) 。 谢谢

AES256encryption在node.js和objective-c之间得到不同的结果

1.Node.js var crypto = require('crypto'); var key = "my password"; var text = "text to encrypt"; var cipher = crypto.createCipher('aes-256-cbc',key); var crypted =cipher.update(text,'utf8','base64'); crypted+=cipher.final('base64'); 结果: ZeYCYOrR / w7qSAZVYht8 + Q == 。目的-C { NSString *key = @"my password"; NSString *text = @"text to encrypt"; NSData *plain = [secret dataUsingEncoding:NSUTF8StringEncoding]; NSData *cipher = [plain AES256EncryptWithKey:key]; NSLog(@"%@\n", […]

在IOS中实现SocketIO

我想在我的项目中实现SocketIO 。 我的项目的服务器端和客户端代码如下。 在客户端,有一个testingbutton,向服务器端发送一个post请求( [self.afn post:@"/test" withParams:@{} completion:^(id obj{})] 。 self.afn是AFNetworking库的包装类的实例对象。 服务器端通过函数app.post('test', function(){…}捕获这个post请求app.post('test', function(){…}在这个post请求处理程序中,我在news频道发出一个数据( {hello: "world"} )我期望在Objective C的SocketIO库的didReceiveMessage处理程序中捕获客户端上的这些数据。 我查了一下,button成功发送发布请求,服务器端成功处理这个发布请求,并在news频道发出数据( hello:"world" )。 但是,客户端不会在didReceiveMessage处理程序上捕获这些数据。 哪里有问题? 你有什么主意吗? 服务器和客户端代码的细节如下: ServerSide: //server.js var express = require('express'); var app = module.exports = express(); /* configure app … */ var io = require('socket.io').listen(8090); var mySocket; io.sockets.on('connection', function (socket) { mySocket = socket; […]