On iOS 15 a long press on the PS Button of the DualSense controller is opening the App Library and I don't receive a callback via the valueChangedHandler function. The App library which will be opened looks like this
This is how I handle all controller inputs:
func handleController(controller: GCController) {
controller.extendedGamepad?.valueChangedHandler = { [weak self] (gamepad: GCExtendedGamepad, element: GCControllerElement) in
guard let self = self else {
return
}
// no feedback received when performing a long press on the PS button
}
Can the game library be suppressed somehow? Sony's PS Remote Play app somehow manages to suppress it, but I don't know how, nor can I find anything in Apple's official API documentation.
Edit: Seems this problem only occurs on iPads, on iPhones this problem doesn't exist. Is there some API or anything on iPads to suppress this behaviour? I assume the most majority of users don't want to open the App Library in the middle of the game.
If someone ever faces the same problem you can actually disable system gestures for the Home button.
In Swift all you have to add is this line (controller is a GCController object)
controller.physicalInputProfile.buttons[GCInputButtonHome]?.preferredSystemGestureState = .disabled
In ObjectiveC it would work like this
controller.physicalInputProfile.buttons[GCInputButtonHome].preferredSystemGestureState = GCSystemGestureStateDisabled;
Thanks to the Apple employee who helped me here
https://developer.apple.com/forums/thread/711905
Edit: on tvOS this isn't working as the PS button (menu button) of a controller always have to act as home event
https://developer.apple.com/forums/thread/715012
Related
I'm working on an IOS swift application that will allow the user to record the entire screen, any app and even the home screen.
In order to do that, I added a Broadcast Upload Extension to my app.
First I used the RPSystemBroadcastPickerView class in order to add a record button to my view that allow the user to open the record popup and select to which app he wants to broadcast the screen flow. And it's working fine :
But I would like to avoid this step and directly open the popup when the app launch.
So I wrote the following code to do that :
RPBroadcastActivityViewController.load(withPreferredExtension: "ch.jroueche.RecordApp.TestScreen", handler: {broadcastAVC,error in
guard error == nil else {
print("Cannot load Broadcast Activity View Controller.")
return
}
if let broadcastAVC = broadcastAVC {
broadcastAVC.delegate = self
self.present(broadcastAVC, animated: true, completion: {
// broadcastactivityviewcontroller will perform the callback when the broadcast starts (or fails)
print("I've START")
})
}
})
Unlikeenter code here the RPSystemBroadcastPickerView solution, I'm getting the following error :
The preferred broadcast service could not be found.
My issue is similar to the following post :
App not showing up as a broadcast service in RPBroadcastActivityViewController
I also added the extension and the preferred extension identifier is correct.
Why would it be possible using the RPSystemBroadcastPickerView and not programmatically using RPBroadcastActivityViewControllerclass. That does not make sense for me.
Does someone have an idea of what could be the issue and how could I fix it ? Or a workaround in order to do this screen record.
Thanks in advance
It appears that RPBroadcastActivityViewController shows ONLY Broadcast Setup UI Extension, while RPSystemBroadcastPickerView shows ONLY Broadcast Upload Extension. But I have no idea why, as both of them are stated to show list of available providers/services.
It would be very helpful if someone could bring more details on the topic.
I'm looking to implement where a OTP is made a suggestion at the top of the keyboard for an OTP Entry in an IOS app.
The IOS version on the phone is 12.2.
THE ISO SDK Version of my App is 12.1.
Using Visual Studio (Windows) 2017 15.9.13
Now I have done the following......
Created an new control public class OTPEntry : Xamarin.Forms.Entry
Created a renderer for the control and in this I do Control.TextContentType = UITextContentType.OneTimeCode;
I then use this control on a ContentPage with the correct namespace etc.
SO when I am on the form with this control, I send a text to the phone with an OTP. On the phone if I click on the code it offers a "Copy Code" option so it is recognised as an OTP.
However, for the life of me, when I tap in the control, to bring up the keyboard, I do not see the code in the top of the keyboard as expected.
What could I possibly be missing?
It seems the steps to implement this are relatively straightforward but I cannot seem to get it working.
Any ideas, pointers would be very greatly appreciated.
Code below...
CONTROL - IN Xamarin Forms Project
namespace XXXX
{
public class OTPEntry : Xamarin.Forms.Entry
{
public OTPEntry()
{
}
}
}
RENDERER - IN IOS Project
namespace XXXX.YYYY.ZZZZ
{
public class OTPEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
Control.TextContentType = UITextContentType.OneTimeCode;
}
...
...
}
}
}
USAGE - IN CONTENT PAGE IN Xamarin Forms Project
<XXXX:OTPEntry x:Name="txtToken" Keyboard="Numeric" Placeholder="Two Factor Code" HeightRequest="50" WidthRequest="300" TextColor="#2A295B" BackgroundColor="White" Margin="0"/>
Firstly,OneTimeCode is available after iOS 12.0.So I suggest add the following code in CustomRenderer
if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
{
Control.TextContentType = UITextContentType.OneTimeCode;
}
What happens is that when an OTP message receives into the Message Inbox, iOS runs a simple text matching algorithm that determines if that message is a valid OTP message or not and based on that keep a track of it in the memory, then when the user clicks on the OTP AutoFill enabled text field in an app, iOS keyboard popup that OTP as a suggestion in the keyboard. So that your users can fill up the OTP into the app without leaving the app or going back into the Messaging app.
You need to check if the format of OTP is correct .One way to verify whether the text message captcha format is legal is to open [SMS] on the iPhone, click on the message captcha, if from the bottom of the call option copy captcha option, can indicate that it is possible;
And don't forget to open the Autofill Passwords in system setting ->account and password .
So - after verification that the code seemed to be OK and has worked for others I was beginning to think I was going crazy.
I then had a look through the phone settings and discovered "Autofill Passwords" which was turned off.
Once I turned it on, this seems to work as expected.
I'm trying to use Replaykit to start a broadcast session (recording the App screen works ok) and it opens up a picker from where broadcasting Apps can be picked, Youtube, Facebook and Periscope show up but not my App, code:
if #available(iOS 10.0, *) {
RPBroadcastActivityViewController.load { broadcastAVC, error in
guard error == nil else {
print("Cannot load Broadcast Activity View Controller.")
return
}
if let broadcastAVC = broadcastAVC {
broadcastAVC.delegate = self
self.viewController.present(broadcastAVC, animated: true, completion: {
// broadcastactivityviewcontroller will perform the callback when the broadcast starts (or fails)
})
}
}
}
Full source code here, the code is in the startBroadcast function.
I also tried loading using withPreferredExtension and it says preferred broadcast service not found. When I go to the control centre to try starting a broadcast session I see no Start Broadcast button and no Apps, just Start Recording, I'm using IOS11 so I tried with a phone using IOS12 and same result concerning control centre.
How can I get my App to show in the picker, thanks?
Had to add the Broadcast Extension, in Xcode, File -> New -> Target -> Broadcast Upload Extension. This extension was then displayed in the picker.
Another common issue is that the Deployment Target for your app (specifically your app, not just your Broadcast Extension) needs to be at least iOS 14.0. If it's any lower, it won't show up even if your device is on the correct version.
I found out how to acknowledge system alerts while on a simulator from this post using this line of code:
self.viewTester.acknowledgeSystemAlert()
Unfortunately, the KIF code has #if TARGET_IPHONE_SIMULATOR wrapped around it, so it won't work on a device. How can I get around permission alerts on a device during automated testing?
I had same issue and here the solution I found:
its right than this KIF function doesn't work on device, its only for simulators! so, You can have a UITest in the UITarget and just a single Test case in it that will add a UIMonitors like this:
// ask for all the permission from users then :
_ = addUIInterruptionMonitor(withDescription: "") { alert -> Bool in
let confirmLabels = ["Allow", "OK"]
for (_, label) in confirmLabels.enumerated() {
let allow = alert.buttons[label]
if allow.exists {
allow.tap()
break
}
}
return true
}
// do some UI interaction here like tapping on some view in app
So you can call this UITest each time before running your UnitTests and that will prepare your app to have all the permissions.
btw, if anyone has better solution please provide cause I wanna know, too ;)
I need to catch sound volume button press inside my react-native application. Couldn't find anything in docs.
You can use react-native-system-setting package with addVolumeListener listener. Something like this
componentDidMount() {
// listen the volume changing
this.volumeListener = SystemSetting.addVolumeListener(data => {
// your action here
});
}
You could create a native module as per FuzzyTree's comment however if you want something that's ready out of the box you could use https://github.com/IFours/react-native-volume-slider and make it hidden. The onValueChange callback is called upon the iOS device volume controls being changed.
Another idea could be to look into the aforementioned module and just take out what you need to form a new module and publish it for the benefit of everyone.