Make outgoing call with CallKit - swift2

I'm actually on swift 2.3.
Inbound Call works great with CallKit. But OutGoing Call ....
I saw the SpeakerBox project, I do the same things.
But it doesn't work.
To start my call, I used
let handle = CXHandle(type: .PhoneNumber, value: "TOTO")
let startCallAction = CXStartCallAction(callUUID: uuid, handle: handle)
startCallAction.video = video
let transaction = CXTransaction()
transaction.addAction(startCallAction)
requestTransaction(transaction)
After, in SpeakerBox Project, this function is called :
func provider(provider: CXProvider, perform action: CXStartCallAction)
But not in my project. Then, when i hangup, i see : "Call failed".
Do you have an idea ?

Be sure you are configuring your CXProvider and setting its delegate properly. If you do not set the CXProvider's delegate property, the delegate will not receive any actions to perform.
Also, if you see a "Call Failed" UI, this may indicate your app is crashing. I'd check for crash logs or run the app in the debugger.

As far as I can see, SpeakerBox demo does not perform the following provider method:
https://developer.apple.com/documentation/callkit/cxprovider/1930701-reportcall
func reportCall(with UUID: UUID,
endedAt dateEnded: Date?,
reason endedReason: CXCallEndedReason)
- (void)reportCallWithUUID:(NSUUID *)UUID endedAtDate:(nullable NSDate
*)dateEnded reason:(CXCallEndedReason)endedReason;
Which leads to the "Call failed" UI screen being displayed - as CallKit was not given a reason why the call has ended, and it seems that "
CXCallEndedReasonFailed" is assumed by default.
Call "reportCall endedAt" before requesting the CXEndCallAction transaction to remove "Call failed" screen.

Have you added the required permissions to your info.plist?

Related

SonarJs still shows warning about postMessage cross-domain issue

The error message is "make sure this cross-domain message is being sent to the intended domain".
This check rule from RSPEC-2819
Authors should not use the wildcard keyword ( *) in the targetOrigin argument in messages that contain any confidential information, as otherwise there is no way to guarantee that the message is only delivered to the recipient to which it was intended.
I assume it demands * cannot be used as targetOrigin, But It still shows warning when I use intended domain as targetOrigin like below:
Please somebody can tell me how to pass this check,
Any help would be appreciated
This rule detects only if a method postMessage is invoked on an object with a name containing window in it. Source code: PostMessageCheck.java. To bypass it, just assign your contentWindow object into different one, like this:
var content = this.elem.contentWindow;
content.postMessage('your message', window.location.origin);
Have faced similar issue in sonarQube. Below fix worked. Just get rid of using window object using directly.
Actual code:
window.parent.postMessage("data", parenturl);
Fix:
var content=window;
content.parent.postMessage("data",parenturl);

onError is not called when Maybe receives null

I am learning how to use Maybe observable. I created the below example. Incase of
Maybe.just(value) I will receive the value in onSuccess callback.
In case of Maybe.just(null), I expected to receive the log from onError. However, according to the posted code, when I run the code, the App crashes and I do not receive any logs.
Would you please tell me why I am not receiving any logs from onError()?
code
Maybe.just(null)
.subscribe(
i->Log.i("TAG:", "[onSuccess]: " + i),
err->Log.e("TAG", "[ERROR] err.getMessage(): " + err.getMessage()),
() -> Log.i("TAG", "[COMPLETED]: ")
);
You can't create a Maybe doing Maybe.just(null). It will throw a NullPointerException, that's why your app crashes.
Some people suggested that the library should have the option to Create a Maybe from null in RxJava, but unfortunately that won't happen:
Closing as won't happen. Static methods returning RxJava types can live on any external class.
A workaround for doing that, is to replace this:
Maybe.just(null)
For this:
Maybe.fromCallable(() -> null)

Array becomes inaccessible during burn API notification chain

I’m writing an app that burns to optical disks and there’s a strange problem when returning from the burn progress panel.
I call the disk recording setup sheet like this:
let setup_panel = DRBurnSetupPanel()
let passed = UnsafeMutableRawPointer(Unmanaged.passUnretained(self.disk_buckets[current_burn_disk]).toOpaque())
setup_panel.beginSetupSheet(for: self.window, modalDelegate: self, didEnd: #selector(self.burnSetupPanelDidEnd(_:return_code:context_info:)), contextInfo: passed)
disk_buckets is an array of classes each containing a reference to a DRTrack to be burnt - I pass an element so that I can deal with the DRTrack reference later.
After the setup panel is dismissed, the following method is then called:
func burnSetupPanelDidEnd(_ panel: DRBurnSetupPanel, return_code: Int, context_info: UnsafeMutableRawPointer) {
//…. some code ….
var track:DRTrack = self.disk_buckets[self.current_burn_disk].vDRTrack!
NotificationCenter.default.addObserver(self, selector: #selector(self.progressDidEnd), name: NSNotification.Name(rawValue: BTVDiscBurnDidEndNotification), object: nil)
self.objc_panel.presentDiscProgressPanel(self.window, burner: panel.burnObject(), layout: track!)
}
objc_panel is a obj-c singleton that initialises and presents a disc burning progress panel (I did it this way as doing it in Swift is buggy - the progress panel is displayed as a tiny window instead of the default OS one - bug report has been sent to Apple). At the end of the burn objc_panel posts the BTVDiscBurnDidEndNotification notification to let the AppDelegate know it’s finished and so to call:
func progressDidEnd(_ note: Notification?) {
print (“DEBUG count: \(self.disk_buckets.count)")
print (“DEBUG first element: \(self.disk_buckets[0])")
//…. more code ….
}
All goes well until the end of the chain when any attempt to access the first element (or any, for that matter) causes a crash:
2016-10-04 14:01:34.654 DiskSpan[4025:220213] *** -[DiskSpan.BackupDisk retain]: message sent to deallocated instance 0x6000cafc0f40
(BackupDisk being the class that populates the array)
However, the first line prints out a correct count of the array i.e. 1. So how come I can't access anything in the array during a notification post?
EDIT: I tried appending a dummy item to the array before reading it back and still the crash only occurs when trying to read the array - not write to it.
It should be noted that this worked under Swift 2 and has only become a problem since Swift 3!
It turns out to be a retention problem. After the call to the obj-c class to start the setup window for burning, the elements in disk_buckets are all over-released. It was a hack but I enumerated over the elements and assigned them to a new array just before calling the setup panel.

Observing changes in HealthKit data using HKObserverQuery

When I setup an HKObserverQuery, the update handler always gets immediately called (something I didn't expect). It also gets called when I add data points through Health.app, as you would expect. I am tending to think I am not doing something right with the completion handler, but the docs are fairly sparse on what is supposed to happen here.
Question: Below is basically what I'm doing. Is this expected behavior, or am I missing something?
func listenForUpdates() {
let bodyMassType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass)
let updateHandler: (HKObserverQuery!, HKObserverQueryCompletionHandler!, NSError!) -> Void = { query, completion, error in
if !error {
println("got an update")
// ... perform a sample query to get the actual data
completion() // is this the right thing to do?
} else {
println("observer query returned error: \(error)")
}
}
let query = HKObserverQuery(sampleType: bodyMassType, predicate: nil, updateHandler: updateHandler)
healthStore?.executeQuery(query)
}
Edit: discovered completion handler should only be called when there wasn't an error, so moved into the !error block. An error is present when the app is not authorized.
Yes, this is expected behavior. The update handler will always be called on first execution so that you can use it to fetch your initial data (from your sample query, anchored object query, etc) and populate your UI.
The completion handler is only necessary if you intend to use background delivery, it informs HealthKit that you have received and processed the data you need so that HealthKit knows to stop launching your app in the background. If you have not registered your app for background delivery, then the completion handler is essentially a no-op and you don't need to worry about it.

Logging an onFailure inError in WebOS

An onFailure handler in webOS has an argument inError. I tried printing it using: console.log("error: " + inError);, but the result is only: error: [object Object]*** (app/assistants/main-assistant.js:26), which isn't much use. How can I log something more useful instead?
Update:
Ares generates: alarm1Failure: function(inSender, inError) {}. However, the error is contained as the errorText property of the first object and the second object is the request
I would use the interactive debugger at:
http://ares.palm.com/AresDebug/
Connect your device and run your app. Put your app name in the 'Script Filter' box and click get scripts.
Now use the 'Available Scripts' pull down to find your assembly.
You can set breakpoints (click on line numbers to the left) and inspect variables using the lower left pane and '>' prompt.
Be sure to use Chrome or Safari as it will not work with IE.
There is also a logger at:
http://ares.palm.com/AresLog/
if you don't want to use the debugger, then you probably should know something about the inError object getting returned to you. In this case I assume the onFailure comes from a Protocol function's callback, so try looking in the Protocol documentation to see what information the error object should contain.
Also for any logging purposes don't forget about the imensely useful function
JSON.stringify(obj)
It will take an object and return a JSON representation that you can log so you can see all the properties at once.

Resources