Apple simple ping not work on iOS why? - ios

I am using apple simple ping source code it works for MAC but not works on iOS.
https://developer.apple.com/library/mac/samplecode/SimplePing/Introduction/Intro.html
below is code I am writing
ping = [SimplePing simplePingWithHostName:#"www.google.com"];
ping.delegate = self;
[ping start];
console response
2016-03-18 18:11:07.252 PinPin[383:49747] >CFHostStartInfoResolution
2016-03-18 18:11:07.256 PinPin[383:49747] <CFHostStartInfoResolution
2016-03-18 18:11:07.334 PinPin[383:49747] >HostResolveCallback
2016-03-18 18:11:07.336 PinPin[383:49747] didStartWithAddress
16-03-18 18:22:42.375 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:44.382 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:46.388 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:48.419 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:50.422 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:52.820 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:54.852 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:56.857 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:22:58.862 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:23:00.844 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:23:02.855 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:23:05.178 PinPin[383:49747] didReceiveUnexpectedPacket
2016-03-18 18:23:07.006 PinPin[383:49747] didReceiveUnexpectedPacket
Nothing happens after this, no other delegate called like
- (void)simplePing:(SimplePing *)pinger didFailWithError:(NSError *)error;
- (void)simplePing:(SimplePing *)pinger didSendPacket:(NSData *)packet;
- (void)simplePing:(SimplePing *)pinger didFailToSendPacket:(NSData *)packet error:(NSError *)error;
- (void)simplePing:(SimplePing *)pinger didReceivePingResponsePacket:(NSData *)packet;
And in readMe.txt apple say
"SimplePing runs on Mac OS X 10.7 and later, although the core code works just fine on all versions of iOS and the underlying approach works on earlier versions of Mac OS X (back to 10.2)."
// UPDATE
MAC. response
Anands-MacBook-Air:~ anand$ cd ~/Downloads/SimplePing
Anands-MacBook-Air:SimplePing anand$ build/Debug/SimplePing www.apple.com
2016-03-19 19:55:48.042 SimplePing[1149:19595] >CFHostStartInfoResolution
2016-03-19 19:55:48.045 SimplePing[1149:19595] <CFHostStartInfoResolution
2016-03-19 19:55:49.490 SimplePing[1149:19595] >HostResolveCallback
2016-03-19 19:55:49.491 SimplePing[1149:19595] pinging 23.211.220.146
2016-03-19 19:55:49.491 SimplePing[1149:19595] #0 sent
2016-03-19 19:55:49.551 SimplePing[1149:19595] #0 received
2016-03-19 19:55:50.493 SimplePing[1149:19595] #1 sent
2016-03-19 19:55:50.557 SimplePing[1149:19595] #1 received
2016-03-19 19:55:51.495 SimplePing[1149:19595] #2 sent
2016-03-19 19:55:51.553 SimplePing[1149:19595] #2 received
2016-03-19 19:55:52.493 SimplePing[1149:19595] #3 sent
2016-03-19 19:55:52.551 SimplePing[1149:19595] #3 received
2016-03-19 19:55:53.493 SimplePing[1149:19595] #4 sent
2016-03-19 19:55:53.551 SimplePing[1149:19595] #4 received
2016-03-19 19:55:54.497 SimplePing[1149:19595] #5 sent
2016-03-19 19:55:54.556 SimplePing[1149:19595] #5 received
2016-03-19 19:55:55.494 SimplePing[1149:19595] #6 sent
2016-03-19 19:55:55.550 SimplePing[1149:19595] #6 received
2016-03-19 19:55:56.492 SimplePing[1149:19595] #7 sent
2016-03-19 19:55:56.551 SimplePing[1149:19595] #7 received
2016-03-19 19:55:57.498 SimplePing[1149:19595] #8 sent
2016-03-19 19:55:57.562 SimplePing[1149:19595] #8 received
2016-03-19 19:55:58.494 SimplePing[1149:19595] #9 sent
2016-03-19 19:55:58.552 SimplePing[1149:19595] #9 received

Try adding this to your didStartWithAddress:
- (void)simplePing:(SimplePing *)pinger didStartWithAddress:(NSData *)address
{
[pinger sendPingWithData:nil];
}

Related

Protobuf dart generation on Mac OS doesn't find protoc-gen-dart

I've installed protoc with homebrew and try to generate dart code with proto files.
When I tried a simple case like protoc --dart_out=. test.proto
it give me:
protoc-gen-dart: program not found or is not executable
--dart_out: protoc-gen-dart: Plugin failed with status code 1.
But protoc-gen-dart is in my path...
I also tried to specify the path like protoc --dart_out=. --plugin=protoc-gen-dart=~/.pub-cache/bin/protoc-gen-dart ./test.proto but same error...
Anyone know how can I fix this ?
EDIT:
echo | ~/.pub-cache/bin/protoc-gen-dart
Unhandled exception:
InvalidProtocolBufferException: CodedBufferReader encountered a malformed varint.
#0 CodedBufferReader._readRawVarint32 (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/coded_buffer_reader.dart:180:5)
#1 CodedBufferReader.readInt32 (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/coded_buffer_reader.dart:109:22)
#2 CodedBufferReader.readBytes (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/coded_buffer_reader.dart:126:18)
#3 CodedBufferReader.readString (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/coded_buffer_reader.dart:132:39)
#4 _mergeFromCodedBufferReader (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/coded_buffer.dart:158:47)
#5 GeneratedMessage.mergeFromBuffer (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/generated_message.dart:159:5)
#6 new GeneratedMessage.fromBuffer (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protobuf-0.10.5/lib/src/protobuf/generated_message.dart:31:5)
#7 new CodeGeneratorRequest.fromBuffer (package:protoc_plugin/src/plugin.pb.dart:88:15)
#8 CodeGenerator.generate.<anonymous closure> (file:///Users/jaumard/.pub-cache/hosted/pub.dartlang.org/protoc_plugin-0.10.5/lib/code_generator.dart:66:25)
#9 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#10 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#11 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#12 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#13 Future._complete (dart:async/future_impl.dart:476:7)
#14 Stream.fold.<anonymous closure> (dart:async/stream.dart:726:18)
#15 _RootZone.runGuarded (dart:async/zone.dart:1302:10)
#16 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
#17 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
#18 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
#19 _SyncStreamController._sendDone (dart:async/stream_controller.dart:771:19)
#20 _StreamController._closeUnchecked (dart:async/stream_controller.dart:628:7)
#21 _StreamController.close (dart:async/stream_controller.dart:621:5)
#22 _Socket._onData (dart:io/runtime/binsocket_patch.dart:1728:21)
#23 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#24 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#25 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#26 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#27 _StreamController._add (dart:async/stream_controller.dart:639:7)
#28 _StreamController.add (dart:async/stream_controller.dart:585:5)
#29 new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1290:35)
#30 _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:819:18)
#31 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#32 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#33 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#34 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
And dtruss output:
sudo dtruss protoc --dart_out=. --plugin=protoc-gen-dart=~/.pub-cache/bin/protoc-gen-dart ./test.proto -I=.
Password:
dtrace: system integrity protection is on, some features will not be available
SYSCALL(args) = return
~/.pub-cache/bin/protoc-gen-dart: program not found or is not executable
--dart_out: protoc-gen-dart: Plugin failed with status code 1.
open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFE5D36050) = 3 0
ioctl(0x3, 0x80086804, 0x7FFEE5D35E60) = 0 0
close(0x3) = 0 0
madvise(0x10A24F000, 0x2000, 0x5) = 0 0
access("/AppleInternal/XBS/.isChrooted\0", 0x0, 0x0) = -1 Err#2
bsdthread_register(0x7FFF65DE2438, 0x7FFF65DE2428, 0x2000) = 1073742047 0
sysctlbyname(kern.bootargs, 0xD, 0x7FFEE5D35170, 0x7FFEE5D35168, 0x0) = 0 0
ioctl(0x2, 0x4004667A, 0x7FFEE5D353F4) = 0 0
mprotect(0x10A2E4000, 0x1000, 0x0) = 0 0
mprotect(0x10A2EB000, 0x1000, 0x0) = 0 0
mprotect(0x10A2EC000, 0x1000, 0x0) = 0 0
mprotect(0x10A2F3000, 0x1000, 0x0) = 0 0
mprotect(0x109ED0000, 0x90, 0x1) = 0 0
mprotect(0x109ED2000, 0x1000, 0x1) = 0 0
mprotect(0x109ED0000, 0x90, 0x3) = 0 0
mprotect(0x109ED0000, 0x90, 0x1) = 0 0
issetugid(0x0, 0x0, 0x0) = 0 0
getentropy(0x7FFEE5D34A40, 0x20, 0x0) = 0 0
getpid(0x0, 0x0, 0x0) = 29452 0
stat64("/AppleInternal\0", 0x7FFEE5D355E0, 0x0) = -1 Err#2
csops(0x730C, 0x7, 0x7FFEE5D35110) = -1 Err#22
proc_info(0x2, 0x730C, 0xD) = 64 0
csops(0x730C, 0x7, 0x7FFEE5D34960) = -1 Err#22
access(".\0", 0x0, 0x0) = 0 0
stat64("/\0", 0x7FFEE5D33EF8, 0x0) = 0 0
getattrlist("/usr\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local/bin\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local/bin/protoc\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
readlink("/usr/local/bin/protoc\0", 0x7FFEE5D34C40, 0x400) = 37 0
getattrlist("/usr/local/Cellar\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local/Cellar/protobuf\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local/Cellar/protobuf/3.6.1.1\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local/Cellar/protobuf/3.6.1.1/bin\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
getattrlist("/usr/local/Cellar/protobuf/3.6.1.1/bin/protoc\0", 0x7FFF65CC0954, 0x7FFEE5D35840) = 0 0
access("/usr/local/Cellar/protobuf/3.6.1.1/bin/google/protobuf/descriptor.proto\0", 0x0, 0x0) = -1 Err#2
access("/usr/local/Cellar/protobuf/3.6.1.1/bin/include/google/protobuf/descriptor.proto\0", 0x0, 0x0) = -1 Err#2
access("/usr/local/Cellar/protobuf/3.6.1.1/include/google/protobuf/descriptor.proto\0", 0x0, 0x0) = 0 0
access("./test.proto\0", 0x0, 0x0) = 0 0
open("./test.proto\0", 0x0, 0x2) = 3 0
close(0x3) = 0 0
open("test.proto\0", 0x0, 0x2) = 3 0
dtrace: error on enabled probe ID 2174 (ID 159: syscall::read:return): invalid kernel access in action #12 at DIF offset 68
dtrace: error on enabled probe ID 2174 (ID 159: syscall::read:return): invalid kernel access in action #12 at DIF offset 68
close(0x3) = 0 0
pipe(0x0, 0x0, 0x0) = 3 0
pipe(0x0, 0x0, 0x0) = 5 0
fork() = 29455 0
close(0x3) = 0 0
close(0x6) = 0 0
sigaction(0xD, 0x7FFEE5D34C78, 0x7FFEE5D34CA0) = 0 0
select(0x6, 0x7FFEE5D35FE0, 0x7FFEE5D35F60, 0x0, 0x0) = 1 0
dtrace: error on enabled probe ID 2172 (ID 161: syscall::write:return): invalid kernel access in action #12 at DIF offset 68
close(0x4) = 0 0
select(0x6, 0x7FFEE5D35FE0, 0x7FFEE5D35F60, 0x0, 0x0) = 1 0
dtrace: error on enabled probe ID 2174 (ID 159: syscall::read:return): invalid kernel access in action #12 at DIF offset 68
close(0x5) = 0 0
wait4(0x730F, 0x7FFEE5D34DD8, 0x0) = 29455 0
sigaction(0xD, 0x7FFEE5D34C78, 0x7FFEE5D34CA0) = 0 0
getrlimit(0x1008, 0x7FFEE5D36160, 0x0) = 0 0
dtrace: error on enabled probe ID 2173 (ID 947: syscall::write_nocancel:return): invalid kernel access in action #12 at DIF offset 68
dtrace: error on enabled probe ID 2173 (ID 947: syscall::write_nocancel:return): invalid kernel access in action #12 at DIF offset 68
dtrace: error on enabled probe ID 2173 (ID 947: syscall::write_nocancel:return): invalid kernel access in action #12 at DIF offset 68
dtrace: error on enabled probe ID 2173 (ID 947: syscall::write_nocancel:return): invalid kernel access in action #12 at DIF offset 68
Ok, looks like protoc passes the argument path directly to execve(), which does not expand the ~ character to mean home directory. Try this instead:
protoc --dart_out=. --plugin=protoc-gen-dart=$HOME/.pub-cache/bin/protoc-gen-dart ./test.proto
In this case $HOME is expanded by the shell before protoc is executed, so it will see the complete path of /Users/yourname/.pub-cache/....
Below are some steps that were used in debugging, they may help others in the future:
Your second command looks like it should work:
protoc --dart_out=. --plugin=protoc-gen-dart=~/.pub-cache/bin/protoc-gen-dart ./test.proto
Perhaps there is something wrong with the executable. You can try executing it directly:
echo | ~/.pub-cache/bin/protoc-gen-dart
If it is properly executable, you should get an error message similar to "google.protobuf.message.DecodeError: Truncated message." because the data from echo is not what the plugin expects. If you get some other error, that could give clues as to why it is not executable.
You can also try tracing protoc with dtruss to find out why the plugin execution fails:
sudo dtruss -f protoc ...
The -f flag is needed to show when protoc tries to start the plugin. There should be a line like this towards the bottom:
execve("~/.pub-cache/bin/protoc-gen-dart", ..) = -1 Err#2
The error number after Err# tells why the execution failed. In my case, it is number 2, which can be looked up in errno.h file:
grep 2 /usr/include/sys/errno.h
...
#define ENOENT 2 /* No such file or directory */
...
Which is because I don't have dart plugin installed. But in your case the error might be something more surprising.

json.decode throws FormatException on nested double quote in json - dart

Below code snippet throws Format Exception in Flutter json decode, Any suggestion please?
import 'dart:async' show Future;
import 'dart:convert';
Future<String> readBooks() async {
String jsonString = '{"description":"As part of the "You Don’t Know JS" series","quantity":55}';
Map<String, dynamic> books = json.decode(jsonString);
return jsonString;
}
Format Exception:
2018-10-23 20:40:30.680 18115-18142/addon.com.bookshop E/flutter:
[ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled
exception:
FormatException: Unexpected character (at character 26)
{"name":"As part of the "You Don’t Know JS" series","Age":55}
^
#0 _ChunkedJsonParser.fail (dart:convert/runtime/libconvert_patch.dart:1358:5)
#1 _ChunkedJsonParser.parse (dart:convert/runtime/libconvert_patch.dart:919:48)
#2 _parseJson (dart:convert/runtime/libconvert_patch.dart:29:10)
#3 JsonDecoder.convert (dart:convert/json.dart:540:36)
#4 JsonCodec.decode (dart:convert/json.dart:167:41)
#5 _MyHomePageState.readBooks (file:///E:/Me/TimePass/flutter/book_shop/lib/main.dart:58:39)
<asynchronous suspension>
#6 _MyHomePageState.build.<anonymous closure> (file:///E:/Me/TimePass/flutter/book_shop/lib/main.dart:48:39)
<asynchronous suspension>
#7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:503:14)
#8 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:558:30)
#9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#10 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
#11 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
#12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
#13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
#14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
#15 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
#16 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
#17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
#18 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue
(package:flutter/src/gestures/binding.dart:64:7)
#19 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket
(package:flutter/src/gestures/binding.dart:48:7)
#20 _invoke1 (dart:ui/hooks.dart:142:13)
#21 _dispatchPointerDataPacket (dart:ui/hooks.dart:99:5)
That's just invalid JSON.
The inner quotes need to be escaped as \" to make your JSON valid.

Google Maps sdk ios Api error

I try to show the map on the simulator and I tried so much to sold this problem but I always have this error how can I fixed please ?
**2016-05-24 14:32:41.295 Menti[40241:2494765] ClientParametersRequest failed, 7 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:32:41.879 Menti[40241:2494765] Google Maps SDK for iOS (M4B) version: 1.13.24482.0
2016-05-24 14:32:42.389 Menti[40241:2494765] ClientParametersRequest failed, 6 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:32:44.661 Menti[40241:2494765] ClientParametersRequest failed, 5 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:32:49.102 Menti[40241:2494765] ClientParametersRequest failed, 4 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:32:57.173 Menti[40241:2494765] ClientParametersRequest failed, 3 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:33:13.234 Menti[40241:2494765] ClientParametersRequest failed, 2 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:33:45.302 Menti[40241:2494765] ClientParametersRequest failed, 1 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:34:49.602 Menti[40241:2494765] ClientParametersRequest failed, 0 attempts remaining (0 vs 7). Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:34:49.602 Menti[40241:2494765] Google Maps SDK for iOS (M4B) cannot connect or validate APIKey: Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>}
2016-05-24 14:34:49.602 Menti[40241:2494765] Your key may be invalid for your bundle ID: com.menti.maps**
You have created a key for your application in google portal right. So in that, you have specified projects bundle identifier. You have to use the same bundle identifier for your application also. And also in App delegate method you have to use the same key.
Please follow the link
1.Google Map Integration for IOS
https://www.codeschool.com/courses/exploring-google-maps-for-ios
Please note below point also
If you want to practice on google maps from iOS devices then just download the GoogleMaps.framework from the below link: https://developers.google.com/maps/documentation/ios/start#getting_the_google_maps_sdk_for_ios
If you want to use GoogleMapsM4B.framework in your project then
You should request support on the Enterprise Support portal(Google's website)
You must enable Google Maps Mobile SDK for Work not Google Maps SDK for iOS in Google’s console website.
You can find the key differences between the Google Maps SDK for iOS and the Google Maps Mobile SDK for Work(M4B) in the below link: https://developers.google.com/maps/documentation/business/mobile/ios/
Hope this will Help You.
Seems like you are using wrong sdk.
as error suggests Google Maps SDK for iOS (M4B) cannot connect or validate APIKey means you are using Google Maps SDK Business version sdk and may be you are using right API key.
import correct Google Maps SDK and use appropriate API key.
#import <GoogleMaps/GoogleMaps.h>
Also check here: not able to use Google map sdk in ios
Just enable "Google Maps SDK for Ios and Android on Google Cloud Platform Console

NSString testing won't evaluate to true when it should

So, I've been trying to get an NSPredicate to work, and it should. But it won't.
I've decided to loop through this array to test how come, and I've gotten to this point with testing
- (void)getItemsForGroup:(NSString *)groupID completion:(MenuQueryBlock)completion{
...
for (NSDictionary *group in [[[[[[self.singleMenuSet objectForKey:#"menuList"] firstObject] objectForKey:#"UnitMenu"] objectForKey:#"data"] objectForKey:#"groups"] objectForKey:#"group"]) {
NSLog(#"test");
NSLog(#"Group MasterGID: %#",[group objectForKey:#"MasterGID"]);
NSLog(#"test_ MasterGID: %#",groupID);
if ([[group objectForKey:#"MasterGID"] isEqualToString:groupID]) {
NSLog(#"Selected Group: %#",group);
}
}
....
completion(....)
}
Here is the section of the log where "Selected Group" should print.
2015-09-02 11:42:24.738 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.738 business_sect[3687:144610] test
2015-09-02 11:42:24.738 business_sect[3687:144610] Group MasterGID: 24000039
2015-09-02 11:42:24.738 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.738 business_sect[3687:144610] test
2015-09-02 11:42:24.738 business_sect[3687:144610] Group MasterGID: 24000040
2015-09-02 11:42:24.738 business_sect[3687:144610] test_ MasterGID: 24000040 <----right after this line
2015-09-02 11:42:24.738 business_sect[3687:144610] test
2015-09-02 11:42:24.739 business_sect[3687:144610] Group MasterGID: 24000041
2015-09-02 11:42:24.739 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.739 business_sect[3687:144610] test
2015-09-02 11:42:24.739 business_sect[3687:144610] Group MasterGID: 24000042
2015-09-02 11:42:24.739 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.739 business_sect[3687:144610] test
2015-09-02 11:42:24.739 business_sect[3687:144610] Group MasterGID: 24000043
2015-09-02 11:42:24.739 business_sect[3687:144610] test_ MasterGID: 24000040
So why isn't the "Selected Group" printing?
Can you try this ?
if ([(NSString *)group[#"MasterGID"] hash] == groupID.hash) {
NSLog(#"Selected Group: %#",group);
}

dart upload file error: FormatException: Bad UTF-8 encoding 0xbf

Here is my server side dart code:
import 'dart:io';
import 'package:http_server/http_server.dart';
void main() {
HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080).then((server) {
server.listen((HttpRequest request) {
if (request.method.toLowerCase() == 'post' && request.uri.path == '/upload') {
HttpBodyHandler.processRequest(request).then((body) {
HttpBodyFileUpload fileUpload = body.body['file'];
File file = new File('aaa');
file.writeAsBytes(fileUpload.content, mode: FileMode.WRITE).then((_) {
request.response.close();
});
});
}
});
});
}
and my error is:
Unhandled exception:
Uncaught Error: FormatException: Bad UTF-8 encoding 0xbf
Stack Trace:
#0 _Utf8Decoder.convert (dart:convert/utf.dart:534)
#1 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:334)
#2 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:330)
#3 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:89)
#4 _handleData (dart:async/stream_transformers.dart:119)
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1020)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:270)
#8 _StreamController&&_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:578)
#9 _StreamController._add (dart:async/stream_controller.dart:453)
#10 _StreamController.add (dart:async/stream_controller.dart:410)
#11 BoundMultipartStream._parse.reportData (package:mime/src/bound_multipart_stream.dart:161:34)
#12 BoundMultipartStream._parse (package:mime/src/bound_multipart_stream.dart:318:28)
#13 BoundMultipartStream.BoundMultipartStream.<anonymous closure>.<anonymous closure> (package:mime/src/bound_multipart_stream.dart:111:24)
#14 _RootZone.runUnaryGuarded (dart:async/zone.dart:1020)
#15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#16 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:270)
#17 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:122)
#18 _ForwardingStream._handleData (dart:async/stream_pipe.dart:86)
#19 _handleData (dart:async/stream_pipe.dart:154)
#20 _RootZone.runUnaryGuarded (dart:async/zone.dart:1020)
#21 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#22 _DelayedData.perform (dart:async/stream_impl.dart:595)
#23 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:711)
#24 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:671)
#25 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#26 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#27 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:126)
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:820)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:126)
Process finished with exit code 255
I used postman to make a post, I chose form-data and add a key called file, value is a txt file.
after send my post to dart server, i got this exception.
is there something wrong with the post ? or the dart code ?
I'm really new to dart, please help me out...
thank you.

Resources