- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 iOS SDK 实现 Sinch,尽管仔细阅读了文档和教程,但我还是不断收到此错误:
2015-08-01 12:29:22.804 neighborfix[55154:2577760] mainUser username - [e-mail username redacted]
2015-08-01 12:29:22.815 neighborfix[55154:2577760] -[UIDevice reb_platform]: unrecognized selector sent to instance 0x7fc113f1ed40
2015-08-01 12:29:22.827 neighborfix[55154:2577760] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDevice reb_platform]: unrecognized selector sent to instance 0x7fc113f1ed40'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a5cac65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a263bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010a5d20ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010a52813c ___forwarding___ + 988
4 CoreFoundation 0x000000010a527cd8 _CF_forwarding_prep_0 + 120
5 neighborfix 0x000000010824fa69 SINUILocalNotificationWithSinchNotification + 13102
6 neighborfix 0x0000000108234817 _ZN6rebrtc13OfflineInvite6encodeERKS0_PhmPm + 4432013
7 neighborfix 0x000000010822f440 _ZN6rebrtc13OfflineInvite6encodeERKS0_PhmPm + 4410550
8 neighborfix 0x0000000108241c79 SINCallOrderByStartTimeComparator + 43762
9 neighborfix 0x00000001082418a0 SINCallOrderByStartTimeComparator + 42777
10 neighborfix 0x0000000107d6ef24 -[AppDelegate sinchClientWithUserId:] + 116
11 neighborfix 0x0000000107d7c31e -[MessagingViewController viewDidLoad] + 574
12 UIKit 0x000000010abbe210 -[UIViewController loadViewIfRequired] + 738
13 UIKit 0x000000010abbe40e -[UIViewController view] + 27
14 UIKit 0x000000010b14b48d -[_UIFullscreenPresentationController _setPresentedViewController:] + 65
15 UIKit 0x000000010ab98da9 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 105
16 UIKit 0x000000010abca288 -[UIViewController _presentViewController:withAnimationController:completion:] + 1761
17 UIKit 0x000000010abcc701 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
18 UIKit 0x000000010abcc625 -[UIViewController presentViewController:animated:completion:] + 229
19 neighborfix 0x0000000107da73e6 -[FixerRequestController submitPressed:] + 230
20 UIKit 0x000000010aa8eda2 -[UIApplication sendAction:to:from:forEvent:] + 75
21 UIKit 0x000000010aa8eda2 -[UIApplication sendAction:to:from:forEvent:] + 75
22 UIKit 0x000000010aba054a -[UIControl _sendActionsForEvents:withEvent:] + 467
23 UIKit 0x000000010ab9f919 -[UIControl touchesEnded:withEvent:] + 522
24 UIKit 0x000000010aadb998 -[UIWindow _sendTouchesForEvent:] + 735
25 UIKit 0x000000010aadc2c2 -[UIWindow sendEvent:] + 682
26 UIKit 0x000000010aaa2581 -[UIApplication sendEvent:] + 246
27 UIKit 0x000000010aaafd1c _UIApplicationHandleEventFromQueueEvent + 18265
28 UIKit 0x000000010aa8a5dc _UIApplicationHandleEventQueue + 2066
29 CoreFoundation 0x000000010a4fe431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
30 CoreFoundation 0x000000010a4f42fd __CFRunLoopDoSources0 + 269
31 CoreFoundation 0x000000010a4f3934 __CFRunLoopRun + 868
32 CoreFoundation 0x000000010a4f3366 CFRunLoopRunSpecific + 470
33 GraphicsServices 0x000000010bea4a3e GSEventRunModal + 161
34 UIKit 0x000000010aa8d900 UIApplicationMain + 1282
35 neighborfix 0x0000000107d7d6df main + 111
36 libdyld.dylib 0x000000010f456145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我试过以下方法:
删除了 Sinch 框架并重新安装了最新版本 (3.5.2)。我确保在删除后我从文件目录中删除了一般的“链接框架和库”中的所有引用和构建阶段中的“链接二进制与库”在重新安装并确保它被复制之前没有引用 Sinch。我已经加载了所有必需的框架[包括那些用于 Parse 冲突的框架](AVFoundation、Security、Audiotoolbox、Bolts、libstc++6.0.9.dylib)和所有必需的链接器标志(-ObjC、-Xlinker、-lc++)。
仔细检查正确的 Sinch 委托(delegate)实现(SINClientDelegate、SINMessageClientDelegate)并将整个 Sinch 委托(delegate)设置/实现移至 AppDelegate 以使其更易于分析。
尝试在真机和模拟器上运行
更改了 Sinch 应用程序设置,以便我的应用程序不需要 JS 身份验证(尽管我认为这不会影响 iOS SDK)。
在整个项目中搜索了任何对 reb_platform 的引用,但没有找到。这可能是 Sinch 库中私有(private)方法的调用。
这是我的相关代码:
AppDelegate.h:
#import <UIKit/UIKit.h>
#import <Sinch/Sinch.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, SINClientDelegate, SINMessageClientDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) id<SINClient> client;
@property (strong, nonatomic) id<SINMessageClient>sinchMessageClient;
- (void)sinchClientWithUserId:(NSString *)userId;
-(void)sendMessage:(NSString *)messageText toRecipient:(NSString *)recipientId;
@end
AppDelegate.m:
#import "AppDelegate.h"
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
#import "Config.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Parse enableLocalDatastore];
// Initialize Parse
[Parse setApplicationId:[APPID]
clientKey:[CLIENT-KEY]];
// rack statistics around application opens.
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
[PFImageView class];
[[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:[UIColor whiteColor]];
//[Fabric with:@[CrashlyticsKit]];
return YES;
}
#pragma mark - Sinch
- (void)sinchClientWithUserId:(NSString *)userId
{
self.client = [Sinch clientWithApplicationKey: [SINCHAPPKEY]
applicationSecret:[SINCHAPPSECRET]
environmentHost:@"sandbox.sinch.com"
userId:userId];
self.client.delegate = self;
[self.client setSupportCalling:NO];
[self.client setSupportMessaging:YES];
[self.client start];
[self.client startListeningOnActiveConnection];
}
- (void)clientDidStart:(id<SINClient>)client
{
NSLog(@"Sinch client started successfully (version: %@)", [Sinch version]);
self.sinchMessageClient = [self.client messageClient];
self.sinchMessageClient.delegate = self;
}
- (void)clientDidFail:(id<SINClient>)client error:(NSError *)error
{
NSLog(@"Sinch client error: %@", [error localizedDescription]);
}
- (void)client:(id<SINClient>)client logMessage:(NSString *)message area:(NSString *)area severity:(SINLogSeverity)severity timestamp:(NSDate *)timestamp
{
if (severity == SINLogSeverityCritical)
{
NSLog(@"%@", message);
}
}
#pragma mark SINMessageClientDelegate methods
// Receiving an incoming message.
- (void)messageClient:(id<SINMessageClient>)messageClient didReceiveIncomingMessage:(id<SINMessage>)message {
[[NSNotificationCenter defaultCenter] postNotificationName:SINCH_MESSAGE_RECEIVED object:self userInfo:@{@"message" : message}];
}
// Finish sending a message
- (void)messageSent:(id<SINMessage>)message recipientId:(NSString *)recipientId {
[[NSNotificationCenter defaultCenter] postNotificationName:SINCH_MESSAGE_SENT object:self userInfo:@{@"message" : message}];
}
// Failed to send a message
- (void)messageFailed:(id<SINMessage>)message info:(id<SINMessageFailureInfo>)messageFailureInfo {
[[NSNotificationCenter defaultCenter] postNotificationName:SINCH_MESSAGE_FAILED object:self userInfo:@{@"message" : message}];
NSLog(@"MessageBoard: message to %@ failed. Description: %@. Reason: %@.", messageFailureInfo.recipientId, messageFailureInfo.error.localizedDescription, messageFailureInfo.error.localizedFailureReason);
}
-(void)messageDelivered:(id<SINMessageDeliveryInfo>)info
{
[[NSNotificationCenter defaultCenter] postNotificationName:SINCH_MESSAGE_SENT object:info];
}
-(void)sendMessage:(NSString *)messageText toRecipient:(NSString *)recipientId{
SINOutgoingMessage *message = [SINOutgoingMessage messageWithRecipient:recipientId text:messageText];
[[self.client messageClient]sendMessage:message];
}
@end
MessagingViewController.h:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import <Sinch/Sinch.h>
@interface MessagingViewController : UIViewController
@property (strong, nonatomic) PFUser *selectedUser;
@end
MessagingViewController.m:
#import "MessagingViewController.h"
#import "UsersTableViewCell.h"
#import "RecipientTableViewCell.h"
#import "TextInsetLabel.h"
#import <Sinch/Sinch.h>
#import "AppDelegate.h"
#import "Config.h"
typedef NS_ENUM(int, MessageDirection)
{
Incoming,
Outgoing
};
@interface MessagingViewController () <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
@property (strong, nonatomic) NSMutableArray *messages;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UITextField *messageTextField;
@property (weak, nonatomic) IBOutlet UIButton *btnSendMessage;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *messagingBottomConstraint;
@end
static NSString * CELL_ID_RECIPIENT = @"RecipientCell";
static NSString * CELL_ID_USER = @"UserCell";
@implementation MessagingViewController{
AppDelegate *delegate;
}
#pragma mark - View Lifecycle
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageDelivered:) name:SINCH_MESSAGE_RECEIVED object:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
//NSLog(@"selectedUser in Messaging - %@",self.selectedUser);
//Init our array to hold chat messages
self.messages = [NSMutableArray new];
//Tableview Setup
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 66.0f;
//Textfield Setup
[self textFieldSetup];
//Setup Sinch message client
PFUser *mainUser = [PFUser currentUser];
NSLog(@"mainUser username - %@",mainUser[@"username"]);
delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate sinchClientWithUserId:mainUser[@"username"]];
}
#pragma mark - Textfield Delegate & Helpers
- (void)textFieldSetup
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification
object:nil];
UITapGestureRecognizer *tap;
tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tap];
}
- (void)keyboardWillShow:(NSNotification *)note
{
CGRect keyboardFrameEnd = [[[note userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
self.messagingBottomConstraint.constant = keyboardFrameEnd.size.height - 24;//Was 48
[UIView animateWithDuration:0.25 animations:^{
[self.view layoutIfNeeded];
}];
[self scrollToBottom];
}
- (void)keyboardWillBeHidden:(NSNotification *)note
{
self.messagingBottomConstraint.constant = 0;
[UIView animateWithDuration:0.25 animations:^{
[self.view layoutIfNeeded];
}];
}
- (void)dismissKeyboard
{
[self.messageTextField resignFirstResponder];
[self scrollToBottom];
}
- (void)scrollToBottom
{
//Scroll to bottom
if (self.messages.count > 0)
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.messages.count - 1 inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
}
#pragma mark - Table View Datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//return self.messages.count;
NSLog(@"self.messages array - %@",self.messages);
return [self.messages count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [UITableViewCell new];
id<SINMessage> message = [self.messages[indexPath.row] firstObject];
MessageDirection direction = (MessageDirection)[[self.messages[indexPath.row] lastObject] intValue];
if (direction == Incoming)
{
cell = [self.tableView dequeueReusableCellWithIdentifier:CELL_ID_RECIPIENT];
((RecipientTableViewCell *)cell).message.text = message.text;
}
else
{
cell = [self.tableView dequeueReusableCellWithIdentifier:CELL_ID_USER];
((UsersTableViewCell *)cell).message.text = message.text;
}
return cell;
}
#pragma mark - Sending Message
- (IBAction)sendMessage:(id)sender
{
[self dismissKeyboard];
NSLog(@"username of recipient - %@",self.selectedUser[@"username"]);
NSString *outgoingMessage = self.messageTextField.text;
[delegate sendMessage:outgoingMessage toRecipient:self.selectedUser[@"username"]];
}
- (void)messageDelivered:(NSNotification *)notification
{
NSString *chatMessage = [[notification userInfo] objectForKey:@"message"];
[self.messages addObject:chatMessage];
[self.tableView reloadData];
[self scrollToBottom];
}
@end
错误显然是由 MessagingViewController.m 中的这一行调用的:
[delegate sinchClientWithUserId:mainUser[@"username"]];
在 AppDelegate 中调用这个方法:
- (void)sinchClientWithUserId:(NSString *)userId
{
self.client = [Sinch clientWithApplicationKey: [SINCHAPPKEY]
applicationSecret:[SINCHAPPSECRET]
environmentHost:@"sandbox.sinch.com"
userId:userId];
self.client.delegate = self;
[self.client setSupportCalling:NO];
[self.client setSupportMessaging:YES];
[self.client start];
[self.client startListeningOnActiveConnection];
}
一些相关的要点:
Xcode 6.3.2, iOS 7.0+
使用 Parse 并将为用户存储的电子邮件用户名用作 Sinch 的用户名
使用 Crashlytics/Fabric
我没有在 Sinch 仪表板上显示任何创建的用户。
感谢任何帮助。 Sinch 看起来是一个非常强大的工具,但我似乎无法使用它。谢谢。
最佳答案
通过删除 Parse FB 实用程序并使用 -all_load 链接器标志,我终于解决了这个问题。 Sinch 客户端现在启动并且错误不再出现。我不确定是什么导致了错误,但似乎与 Sinch 和 Parse FB Utils 有一些冲突。我已经按照 Sinch 的说明加载额外的库和框架来解决任何此类冲突,但显然这还不够。
关于ios - Sinch iOS - 'NSInvalidArgumentException' , '-[UIDevice reb_platform] : unrecognized selector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31764577/
我在这里撕扯我的头发。已阅读许多描述如何解决此问题的示例,但没有一个可以帮助我解决该问题。 在 UIView 上有一个链接到 IBAction 的简单按钮。 代码是这样的... 联系方式.h #imp
我在 map 中有一些注解 View ,我希望通过touchUpInside打开一个新的ViewController,但出现此错误: Terminating app due to uncaught
我想尝试一下群众的智慧……因为我现在很沮丧。提前致谢。 这是我的代码: - (void)imagePickerController:(UIImagePickerController *)ipc did
我遇到以下问题。我继承了一个应用程序,我正在尝试修改它。原始功能允许我添加带有一些文本注释的任务。我想添加一个图标以使其更具视觉吸引力。当我修改代码签名以传递图标时(实际上我只是在 NSString
[__NSArrayM relatedObjectDidChange]: unrecognized selector sent to instance error Class: NSInvalidAr
我有两个viewController,都带有一个表,应用程序可以工作,然后我在第二个viewController 中添加了导航栏,让他有机会在第一个viewController 中返回。导航栏可以工作
通常应用程序运行良好,但我在 Crashlytics 中收到问题。一周发生1-2次。适合 2k-3k 用户。应用程序适用于 iOS 7 及更高版本。报告:致命异常:NSInvalidArgumentE
此函数旨在获取 JSON 并根据作为参数发送的对象创建对象数组: + (NSArray *)Object: (id) object FromJSON:(NSData *)objectNotation
尝试将核心数据对象获取到tableview并获得Terminating app due to uncaught exception 'NSInvalidArgumentException', reas
我设计了一个应用程序,它将有一个按钮和三个标签。 当按下按钮时,将调用一个URL。 URL的JSON表示如下: [ { "_id": "50c87e8a1898044ea1458e4c",
我以编程方式实现了自动布局。 self.rightSideLine = [[UIView alloc] init]; self.rightSideLine.backgroundColor = COLO
我有一个 iOS 应用程序,可以在 Appstore 中找到。今天我测试了该应用程序,当应用程序尝试打开错误对话框时,它在我的 iPhone4 (iOS7) 上崩溃了。在 iPhone5s 上没有问题
我在其他地方使用“正常工作”的代码时遇到错误: [Error]: Caught "NSInvalidArgumentException" with reason "*** -[_NSPlacehold
我正在编写代码以向图片添加滤镜。这是代码 func applyFilter(index: Int){ print("Applying Filter....") //let contex
我正在练习创建一个主要不使用 Storyboard的 UI,当我开始调试时,我的应用程序崩溃了,并给我带来了这个错误。 我尝试从 info.plist 和目标中删除“main”,但不起作用 2019-
我有一个 tableView,我在一个单元格上创建了一个 Button。 UIButton *deleteGroupButton = [UIButton buttonWithType:UIButt
这是我的代码: @interface TabRegsViewController () @end @implementation TabRegsViewController @synthesize p
即使在这个项目之前我从未在 Objective-C 中工作过或制作过 iOS 应用程序,但我处于必须支持其他人代码的“令人敬畏”的位置,所以如果我做了一些非常明显或愚蠢的事情,请原谅. 我需要一个带有
我的代码抛出以下异常: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_
我有一个无法理解的问题,我正在使用一个用于使用Map Open Source Map(https://github.com/route-me/route-me)的库,该示例运行完美,并且我相信不是与代
我是一名优秀的程序员,十分优秀!