Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
Update/go sdk (#73) (#74)
Browse files Browse the repository at this point in the history
* go-sdk: update 'NINLowLevelClient.framework'

* user-agent: add support for 'user-agent' header
- Added 'User-agent' header to 'NINChatSession'
- Updated 'NINLowLevelClient' to 0.0.40 (was 0.0.11)

* fix: resolve comments and bugs
- Update to fix #61 bug in some cases.
- Update appVersion to sdkVersion
- Update user-agent value in different 'nil' paramter cases
- Update README and LICENSE
  • Loading branch information
Hassan Shahbazi authored Jan 23, 2020
1 parent 6322d06 commit be07754
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
- (nullable instancetype)init;
- (NINLowLevelClientEvents* _Nullable)call:(NINLowLevelClientProps* _Nullable)params payload:(NINLowLevelClientPayload* _Nullable)payload error:(NSError* _Nullable* _Nullable)error;
- (void)setAddress:(NSString* _Nullable)address;
- (void)setHeader:(NSString* _Nullable)key value:(NSString* _Nullable)value;
@end

@interface NINLowLevelClientEvent : NSObject <goSeqRefInterface> {
Expand Down Expand Up @@ -170,12 +171,13 @@
- (BOOL)open:(NSError* _Nullable* _Nullable)error;
- (BOOL)send:(NINLowLevelClientProps* _Nullable)params payload:(NINLowLevelClientPayload* _Nullable)payload actionId:(int64_t* _Nullable)actionId error:(NSError* _Nullable* _Nullable)error;
- (void)setAddress:(NSString* _Nullable)address;
- (void)setOnClose:(id<NINLowLevelClientCloseHandler> _Nullable)callback;
- (void)setOnConnActive:(id<NINLowLevelClientConnActiveHandler> _Nullable)callback;
- (void)setOnConnState:(id<NINLowLevelClientConnStateHandler> _Nullable)callback;
- (void)setOnEvent:(id<NINLowLevelClientEventHandler> _Nullable)callback;
- (void)setOnLog:(id<NINLowLevelClientLogHandler> _Nullable)callback;
- (void)setOnSessionEvent:(id<NINLowLevelClientSessionEventHandler> _Nullable)callback;
- (void)setHeader:(NSString* _Nullable)key value:(NSString* _Nullable)value;
- (void)setOnClose:(id<NINLowLevelClientCloseHandler> _Nullable)h;
- (void)setOnConnActive:(id<NINLowLevelClientConnActiveHandler> _Nullable)h;
- (void)setOnConnState:(id<NINLowLevelClientConnStateHandler> _Nullable)h;
- (void)setOnEvent:(id<NINLowLevelClientEventHandler> _Nullable)h;
- (void)setOnLog:(id<NINLowLevelClientLogHandler> _Nullable)h;
- (void)setOnSessionEvent:(id<NINLowLevelClientSessionEventHandler> _Nullable)h;
- (BOOL)setParams:(NINLowLevelClientProps* _Nullable)params error:(NSError* _Nullable* _Nullable)error;
@end

Expand All @@ -191,6 +193,8 @@
- (NSString* _Nonnull)string;
@end

FOUNDATION_EXPORT NSString* _Nonnull NINLowLevelClientDefaultUserAgent(void);

FOUNDATION_EXPORT NINLowLevelClientCaller* _Nullable NINLowLevelClientNewCaller(void);

FOUNDATION_EXPORT NINLowLevelClientJSON* _Nullable NINLowLevelClientNewJSON(NSString* _Nullable s);
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions NinchatLowLevelClient.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Pod::Spec.new do |s|
s.name = "NinchatLowLevelClient"
s.version = "0.0.11"
s.version = "0.0.40"
s.summary = "Low-level communications library for Ninchat messaging."
s.description = "For providing low-level communications using Ninchat messaging."
s.homepage = "https://ninchat.com/"
s.license = { :type => "Ninchat", :file => "LICENSE.md" }
s.author = { "Matti Dahlbom" => "[email protected]" }
s.license = { :type => "BSD", :file => "LICENSE.md" }
s.author = { "Hassan Shahbazi" => "[email protected]" }
s.source = { :git => "https://github.com/somia/ninchat-sdk-ios.git", :tag => "#{s.version}" }

s.ios.deployment_target = "9.0"
Expand Down
7 changes: 3 additions & 4 deletions NinchatSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

Pod::Spec.new do |s|
s.name = "NinchatSDK"
s.version = "0.0.39"
s.version = "0.0.40"
s.summary = "iOS SDK for Ninchat."
s.description = "For building iOS applications using Ninchat messaging."
s.homepage = "https://ninchat.com/"
s.license = { :type => "Ninchat", :file => "LICENSE.md" }
s.author = { "Matti Dahlbom" => "[email protected]",
"Hassan Shahbazi" => "[email protected]" }
s.license = { :type => "BSD", :file => "LICENSE.md" }
s.author = { "Hassan Shahbazi" => "[email protected]" }
s.source = { :git => "https://github.com/somia/ninchat-sdk-ios.git", :tag => "#{s.version}" }

s.ios.deployment_target = "9.0"
Expand Down
4 changes: 2 additions & 2 deletions NinchatSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 40;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down Expand Up @@ -1258,7 +1258,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 39;
CURRENT_PROJECT_VERSION = 40;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ extern NSString* _Nonnull const kNINMessageTypeWebRTCHangup;
/** List of Audience queues. These are the queues the user gets to pick from in the UI. */
@property (nonatomic, strong) NSArray<NINQueue*>* _Nonnull audienceQueues;

/** Host application details including name, version, and some more details.
* will be appended to some predefined values such as SDK version, device OS, and device model.
*/
@property (nonatomic, strong) NSString* _Nullable appDetails;

/** Whether or not this session is connected. */
@property (nonatomic, assign, readonly) BOOL connected;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "NINFileInfo.h"
#import "NINToast.h"
#import "NINMessageThrottler.h"
#import <sys/utsname.h>

// UI texts
static NSString* const kConversationStartedText = @"Audience in queue {{queue}} accepted.";
Expand Down Expand Up @@ -950,6 +951,35 @@ -(void) handleError:(NINLowLevelClientProps*)params {
postNotification(kActionNotification, @{@"action_id": @(actionId), @"error": newError(errorType)});
}

-(NSString*)sdkDetails {
NSString *details = @"ninchat-sdk-ios";

/// SDK Version
NSString* sdkVersion = [[findResourceBundle() infoDictionary] objectForKey:@"CFBundleShortVersionString"];
if (sdkVersion != nil)
details = [details stringByAppendingString:[NSString stringWithFormat:@"/%@", sdkVersion]];

/// Device OS
details = [details stringByAppendingString:@" (ios "];
NSString* operatingSystem = [[UIDevice currentDevice] systemVersion];
if (operatingSystem != nil)
details = [details stringByAppendingString:[NSString stringWithFormat:@"%@", operatingSystem]];
details = [details stringByAppendingString:@";"];

/// Device Model
struct utsname systemInfo;
uname(&systemInfo);
NSString* model = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
if (model != nil)
details = [details stringByAppendingString:[NSString stringWithFormat:@" %@", model]];
details = [details stringByAppendingString:@")"];

if (self.appDetails != nil)
details = [details stringByAppendingString:[NSString stringWithFormat:@" %@", self.appDetails]];

return details;
}

#pragma mark - Public methods

-(BOOL) connected {
Expand Down Expand Up @@ -1358,7 +1388,8 @@ -(NSError*) openSession:(startCallbackBlock _Nonnull)callbackBlock {
[self.session setOnLog:self.sessionCallbackHandler];
[self.session setOnSessionEvent:self.sessionCallbackHandler];
[self.session setOnEvent:self.sessionCallbackHandler];

[self.session setHeader:@"User-Agent" value:[self sdkDetails]];

NSError* error = nil;
[self.session setParams:sessionParams error:&error];
if (error != nil) {
Expand Down
8 changes: 8 additions & 0 deletions NinchatSDK/NINChatSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
/** Value to be passed as audience_metadata parameter for request_audience calls. */
@property (nonatomic, strong) NINLowLevelClientProps* _Nullable audienceMetadata;

/**
* Append information to the user agent string. The string should be in
* the form "app-name/version" or "app-name/version (more; details)".
*
* Set this prior to calling startWithCallback:
*/
@property (nonatomic, strong) NSString* _Nullable appDetails;

/**
* Initializes the API using default environment.
*
Expand Down
8 changes: 8 additions & 0 deletions NinchatSDK/NINChatSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ -(void) setAudienceMetadata:(NINLowLevelClientProps*)audienceMetadata {
self.sessionManager.audienceMetadata = audienceMetadata;
}

-(void)setAppDetails:(NSString *)appDetails {
self.sessionManager.appDetails = appDetails;
}

-(NSString*)appDetails {
return self.sessionManager.appDetails;
}

-(NINLowLevelClientProps*) audienceMetadata {
return self.sessionManager.audienceMetadata;
}
Expand Down
4 changes: 2 additions & 2 deletions NinchatSDK/WebRTC/NINWebRTCClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ -(void) startLocalCapture {
NSInteger fps = [self selectFpsForFormat:format];
NSLog(@"Using FPS: %ld for local capture", (long)fps);

/// The issue with the output: `https://github.com/somia/ninchat-sdk-ios/issues/61`
[self setAudioOutputToSpeaker];
[self.localCapturer startCaptureWithDevice:device format:format fps:fps completionHandler:^(NSError * _Nonnull error) {
if (error != nil) {
[self.sessionManager.ninchatSession sdklog:@"** ERROR failed to start local capture: %@", error];
Expand Down Expand Up @@ -410,6 +408,8 @@ -(void) startWithSDP:(NSDictionary*)sdp {

__weak typeof(self) weakSelf = self;

/// The issue with the output: `https://github.com/somia/ninchat-sdk-ios/issues/61`
[self setAudioOutputToSpeaker];
// Start listening to WebRTC signaling messages from the chat session manager
self.signalingObserver = fetchNotification(kNINWebRTCSignalNotification, ^BOOL(NSNotification* note) {
NSDictionary* payload = note.userInfo[@"payload"];
Expand Down
5 changes: 1 addition & 4 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
platform :ios, '9.0'
use_frameworks!

#source 'https://github.com/CocoaPods/Specs.git'

# Changing the source URL
# according to the thread: https://stackoverflow.com/questions/58958185/travis-ci-gets-stuck-in-pods-installation
source 'https://cdn.cocoapods.org/'
source 'https://github.com/somia/ninchat-podspecs.git'

def all_pods
pod 'AFNetworking', '~> 3.0'
pod 'NinchatLowLevelClient', '~> 0'
pod 'NinchatLowLevelClient', '~> 0.0.40'
pod 'GoogleWebRTC', '~> 1.1'
#pod 'NinchatLowLevelClient', :path => '.'
end

target 'NinchatSDK' do
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ self.ninchatSession.delegate = self

##### Optional parameters

* `siteSecret` is optional and may not be required for your deployment
* `environments` is optional and may not be required for your deployment
* `queueID` define a valid queue ID to join the queue directly; specify nil to show queue selection view.

##### User Agent Header (Optional)

To append information as the user agent header to your requests, use the following format to set value to `appDetails` prior to call `start(callBack:)` function:

```swift
ninchatSession.appDetails = "app-name/version (more; details)"
```

#### Starting the API client

The SDK must perform some asynchornous networking tasks before it is ready to use; this is done by calling the `start` method as follows:
Expand Down Expand Up @@ -246,4 +254,4 @@ These keys can be found in the SDK's public header `NINPublicTypes.h`. For Objec
## Contact

If you have any questions, contact:
* Matti Dahlbom / Qvik <matti@qvik.com>
* Hassan Shahbazi / Ninchat <hassan@ninchat.com>

0 comments on commit be07754

Please sign in to comment.