Programming native vibration to work on iOS through AS3 - ios

I've made a tester class to test the vibration on an iPod Touch but the vibration doesn't work when tested on the device. I've imported all relevant extensions and linked to the relevant Adobe AIR library classes as per this question and answer. Am I using a wrong callback or something?
package
{
import flash.display.Sprite;
import com.adobe.nativeExtensions.Vibration;
public class Test extends Sprite
{
public function Test()
{
run();
}
public function run(): void {
var vibe:Vibration;
if (Vibration.isSupported)
{
vibe = new Vibration();
vibe.vibrate(25000);
}
}
}
}
EDIT: Found out that iPod Touches don't have vibration sensor. After testing this on an iPhone 5, it still doesn't work. As soon as the app is launched, it crashes (and closes) without vibrating.

iPod Touch do not support vibration. :)

Related

Testing a Swift Package that uses Bluetooth

I am writing unit tests for a class in a Swift Package for use with iOS. The class being tested (BleCommunicator) uses Bluetooth but the test in question does not. I cannot run the test because I get the error below as the class under test is instantiated:
"State restoration of CBCentralManager is only allowed for applications that have specified the "bluetooth-central" background mode (NSInternalInconsistencyException)"
The solution for an app would be to add the bluetooth-central entry into the Info.plist file. How can this be handled for a Swift Package?
Thanks in advance for the help!
class BleCommunicatorTests: XCTestCase {
var sut: BleCommunicator!
override func setUpWithError() throws {
try super.setUpWithError()
sut = BleCommunicator()
}
func test_WhenSavingSomething_AFileShallBeCreated() {
...
}

Implemented iOS AppIntents don't show in Shortcuts

I'm trying to test out the new AppIntents API that is currently on iOS16 Beta. Looking at the documentation, the implementation seems pretty straight forward, but after implementing it, I'm not seeing my AppIntent in the Shortcuts app. The device is running iOS 16.0.
This is how I implemented the AppIntent:
import AppIntents
struct DoSomethingIntent: AppIntent {
static var title: LocalizedStringResource = "This will do something"
static var description = IntentDescription("Does something")
func perform() async throws -> some PerformResult {
return .finished(value: "Done")
}
}
According to the documentation the Shortcuts app should be able to find my AppIntent after my app gets installed, but I see that's not the case. Does anybody know what my implementation is missing?
AppIntents APIs are a little bit new and have strange behaviours and the documentation is very poor.
In my case, I was able to make them work by adding the \(.applicationName) parameter to the phrase. Try this:
struct LibraryAppShorcuts: AppShortcutsProvider {
#AppShortcutsBuilder static var appShortcuts: [AppShortcut] {
AppShortcut(intent: DoSomethingIntent(), phrases: ["Do something with \(.applicationName)"])
}
}
First you need to select your Xcode-beta.app via xcode-select
Clean derived data
Kill your app & shortcut app
Add a shortcut library in your code
struct LibraryAppShorcuts: AppShortcutsProvider {
#AppShortcutsBuilder static var appShortcuts: [AppShortcut] {
AppShortcut(intent: DoSomethingIntent(), phrases: ["My something phrase"])
}
}
Build

Access Unity 3d UI component like Panel/Image as a view in Objective C code

I have a certain task where i want to pass a UIView to one of the SDK's in my iOS project.
Now, my project is a simple 2D game build in Unity 3d. I want to send the Panel in my Canvas to that SDK as UIView.
I am aware of iOS and Unity communication. It happens using as Char*.
I am not sure how should i access that GameObject Panel in my iOS code as UIView. I will be very thankful if i receive any help on this.
Above is one of solution that you can access from ios interface but before see this, read https://docs.unity3d.com/Manual/PluginsForIOS.html. it will help to understand how unity and native code can communicate.
iOS: test.mm
#import "Unity/UnityInterface.h"
...
...
-(void)SendMessage
{
UnitySendMessage("MessageGameCommunicator", "Receiver", [message UTF8String]);
}
Unity: Commnicator.cs, MessageGameCommunicator (GameObject name)
public class Commnicator : MonoBehaviour
{
public static void Receiver(string message)
{
// ...
// Do something.
}
}
After Unity interface get message from ios, you can implement whatever you want.

How to Control iOS device volume with Unity?

I developed Enterprise App, and installed it to my iPad.
The problem is that the iPad will be built in the wall, so it will not be possible to access the volume buttons.
I want to control the volume during the exhibition. I made UIButtons "-" and "+" to control the volume of the device instead of real volume button, not the Unity audio component's volume. I researched several times, so now what should I do in Unity?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
public class IOSManager : MonoBehaviour {
public static IOSManager _instance;
[DllImport("__Internal")]
private static extern void iosVolumeMinus();
private static extern void iosVolumePlus();
void Awake(){
_instance = this;
}
public void CallMinusFunc()
{
iosVolumeMinus();
}
public void CallPlusFunc()
{
iosVolumePlus();
}
}
Well, I tried somethings and realized that MPMusicPlayerController And MPVolumeView may work, but had some problems.
If I use MPMusicPlayerController I get
alert : 'volume' is deprecated:
first deprecated in iOS 7.0 - Use MPVolumeView for volume control.
But if I use MPVolumeView I get
alert : Incomplete definition of type 'struct
objc_class'.
It is my first time developing an iOS app, so I don't know what the problem is.

PhoneGap Build Difficulty

I'm getting started with PhoneGap on iOS and not having much luck. My app is stuck on the splash screen and nothing is shown in Phoegap Build's console.
The screenshot at http://i.imgur.com/Ru9n3ET.png shows both my file structure and skeleton code. The only thing I see from the app is the alert of '1' called from body's onload event. Nothing else is shown. Is there a glaring mistake which is killing the app?
alert(1) is coming from javaScript and you has nothing to do with phonegap.
You would want to make sure that your code directory has the necessary API's that call Phonegap code. It would look like something below:
package com.news.newsfinder;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
You must have cordova.jar in your build path and cordova.js in your js directory.
Then your javascript code to call phonegap API's can become something like this.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
checkConnection();
}
function checkConnection() {
//code to check what type of internet connection a device is using, wifi, 2G, 3G...
}
The above code which has a package com.news.newsfinder will make an APP in play store like below:
http://play.google.com/store/apps/details?id=com.news.newsfinder

Resources