Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Voorneveld committed Jan 9, 2017
2 parents 72c7a52 + 5b7f484 commit 8396637
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 263 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
All notable changes to this project will be documented in this file.

---
## [2.1.0](https://github.com/VoIPGRID/VialerSIPLib/tree/2.1.0) (01/09/2017)
Released on Monday, January 9, 2017.

#### Added
* Bluetooth routes can be changed (#26)[https://github.com/VoIPGRID/VialerSIPLib/pull/26]


#### Fixed
* Updated documentation (#24)[https://github.com/VoIPGRID/VialerSIPLib/pull/24]
* Start network monitoring only when there is a call active (#34)[https://github.com/VoIPGRID/VialerSIPLib/pull/34]
* Network changes are delayed a little to prevent multiple register attempts (8c4c96a)[https://github.com/VoIPGRID/VialerSIPLib/commit/8c4c96ac76c4535abf47629dfe23b2c74a6498c7]


## [2.0.1](https://github.com/VoIPGRID/VialerSIPLib/tree/2.0.1) (12/09/2016)
Released on Friday, December 9, 2016.
Expand Down
139 changes: 131 additions & 8 deletions Documentation/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
Getting started with the VialerSIPLib (W.I.P.)
==============================================

There are 3 steps to getting started with the library.
There are 4 steps to getting started with the library.

1. Add the VialerSIPLib files to your project
2. Create and configure the library
3. Add an Account to the library
4. Set callback to accept incoming calls
5. Create outbound calls

After these steps, the library is up and running and ready for action. We suggest that you create a proper middleware setup that will push a VoIP notification to the app. The app should call `[VialerSIPLib sharedInstance] registerAccount:]` when receiving the notification to make sure there is a proper registration.

#### 1. Add the VialerSIPLib to your project
### 1. Add the VialerSIPLib to your project

##### CocoaPods
#### CocoaPods

```ruby
platform :ios, '9.0'
pod 'VialerSIPLib'
```

#### 2. Create and configure the library
### 2. Create and configure the library

Configure the library with an Endpoint Configuration. At this moment, we have some difficulties with TCP connections, so we stick to UDP. After you configured the library, it is started automatically.
Configure the library with an Endpoint Configuration. After you configured the library, it is started automatically.

Objective-C
```objective-c
VSLEndpointConfiguration *endpointConfiguration = [[VSLEndpointConfiguration alloc] init];
VSLTransportConfiguration *updTransportConfiguration = [VSLTransportConfiguration configurationWithTransportType:VSLTransportTypeUDP];
Expand All @@ -36,10 +38,11 @@ Configure the library with an Endpoint Configuration. At this moment, we have so
}
```
#### 3. Add an Account to the library
### 3. Add an Account to the library
Add a user to the libary. The user can be of any class, as long the calls implements the `SIPEnabledUser` protocol. We suggest to set `sipRegisterOnAdd` to NO. This will prevent pjsip to register at the provided domain.
Objective-C
```objective-c
SipUser *testUser = [[SipUser alloc] init];
testUser.sipAccount = KeysAccount;
Expand All @@ -54,9 +57,129 @@ Add a user to the libary. The user can be of any class, as long the calls implem
NSLog(@"Failed to create Account: %@", error);
}
```
### 4. Inbound calls

#### 4. Set callback for incoming calls
#### 1. AppDelegate - instantiate CallKitProviderDelegate to a private property

Objective-C
```objective-c
TODO
- (CallKitProviderDelegate *)callKitProviderDelegate {
if !(_callKitProviderDelegate) {
_callKitProviderDelegate = [[CallKitProviderDelegate alloc] initWithCallManager:[[VialerSIPLib sharedInstance].callManager]];
}
return _callKitProviderDelegate;
}
```
Swift
```swift
var providerDelegate: CallKitProviderDelegate?
providerDelegate = CallKitProviderDelegate(callManager: VialerSIPLib.sharedInstance().callManager)
```

#### 2. Adapt the incoming call callback block.

Objective-C
```objective-c
[VialerSIPLib sharedInstance].incomingCallBlock = ^(VSLCall * _Nonnull call) {
if ([VialerSIPLib callKitAvailable]) {
[self.callKitProviderDelegate reportIncomingCall:call];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
__weak AppDelegate *weakSelf = self;
if ([SIPUtils anotherCallInProgress:call]) {
NSError *error;
[call decline:&error];
if (error) {
NSLog(@"Error declining call: %@", error);
}
} else {
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
// Your code here
} else {
// Your code here
}
}
});
}
};
```
#### 3. The CallKit provider delegate informs your app about incoming calls through 2 notifications:
- CallKitProviderDelegateOutboundCallStarted
- CallKitProviderDelegateInboundCallAccepted
These notification should be used by your app to display the appropriate calling screen.
When receving this notification, a VSLCall object is sent with it an can by found in the notification's
user info dict with the key: VSLNotificationUserInfoCallKey.
All operations on a VSLCall should now be done through the new VSLCallManager class. This means:
- starting a call to a number
- answering an inbound call
- ending a call
- toggle mute and hold
- sending DTMF tones
You can also query the CallManger for a call based on "UUID" or "PJSIP call ID".
### 5. Outbound calls
Use the new VSLCallManager -startCall function to instantiate an outbound call.
To be able to use the app through a native iOS interface, e.g. recents or contacts, you will need to create an "Intent Extension".
This is done by creating a new "target" and selecting "Intent Extension". You will see a new target and also a folder with the same name as the extension you've just created with 2 files in it (at least for swift) IntentHandler.swift and info.plist.
Replace the contents of IntentHandler.swift with:
Swift
```swift
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
Intents handler principal class
*/
import Intents
class IntentHandler: INExtension, INStartAudioCallIntentHandling {
func handle(startAudioCall intent: INStartAudioCallIntent, completion: @escaping (INStartAudioCallIntentResponse) -> Void) {
let response: INStartAudioCallIntentResponse
defer { completion(response) }
// Ensure there is a person handle
guard intent.contacts?.first?.personHandle != nil else {
response = INStartAudioCallIntentResponse(code: .failure, userActivity: nil)
return
}
let userActivity = NSUserActivity(activityType: String(describing: INStartAudioCallIntent.self))
response = INStartAudioCallIntentResponse(code: .continueInApp, userActivity: userActivity)
}
}
```

Modifiy the info.plist. The "NSExtension" dictionary item needs te get a "NSExtensionAttributes" item With an Array item called "IntentsSupported" which will get 1 item, a String "Item 0" and it's value should be "INStartAudioCallIntent"

Add the A NSUserActivity Extension to your project. Code -> NSUserActivity+StartCallConvertible.swift
And the class: StartCallConvertible.swift used by the extension.

When the user wants to start an oubound call through the native interface using your app the following app delegate function will be called:

Objective-C
```objective-c
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler;
```

Swift
```swift
optional func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool
```

You can obtain the phone number through:

Objective-C
```ojective-c
NSString *handle = userActivity.startCallHandle;
```

Swift
```swift
let handle = userActivity.startCallHandle
```
Than start a call to the number using the sip lib just like you would do from within your app.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PODS:
- OCMock (3.3.1)
- Reachability (3.2)
- Vialer-pjsip-iOS (1.1.0)
- VialerSIPLib (1.0.6):
- VialerSIPLib (2.0.1):
- CocoaLumberjack
- Reachability
- Vialer-pjsip-iOS
Expand All @@ -30,7 +30,7 @@ SPEC CHECKSUMS:
OCMock: f3f61e6eaa16038c30caa5798c5e49d3307b6f22
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
Vialer-pjsip-iOS: ced3608a20ffdcdf4afdc84a8e381c57525f8f25
VialerSIPLib: a544d577e75e1f3f08c85c55d667749bae1a1e57
VialerSIPLib: b06eb9e5a3ded1f856bbac59311289dd8ef97959

PODFILE CHECKSUM: 0f7b04fb045caf39ed7c2486524959b2d2be90e8

Expand Down
Loading

0 comments on commit 8396637

Please sign in to comment.