[iOS]Call vibration

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

[iOS]Call vibration

Postby Lena » Sat Oct 08, 2016 12:38 am

In my iOS application I show the dialog box. How to add a call the phone vibrates at the time of the show this window?
Lena
BCBJ Master
BCBJ Master
 
Posts: 454
Joined: Sun Feb 06, 2011 1:28 pm

Re: [iOS]Call vibration

Postby Lena » Mon Oct 10, 2016 6:58 am

I try use iOSapi.AudioToolbox.pas from this link:
https://github.com/FMXExpress/ios-object-pascal-wrapper
When build:
[DCC Fatal Error] iOSapi.AudioToolbox.pas(22): F2613 Unit 'Macapi.Foundation' not found.
Is it possible use iOSapi.AudioToolbox.pas in C++ Builder 10.1 (iOS).
I want use:
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

or help me translate in C++:
http://community.embarcadero.com/blogs/ ... ey-and-xe8
Lena
BCBJ Master
BCBJ Master
 
Posts: 454
Joined: Sun Feb 06, 2011 1:28 pm

Re: [iOS]Call vibration

Postby Lena » Sun Oct 16, 2016 8:23 am

rlebeau, try to help me here:
https://forums.embarcadero.com/thread.j ... 5&tstart=0
THank You!
Lena
BCBJ Master
BCBJ Master
 
Posts: 454
Joined: Sun Feb 06, 2011 1:28 pm

Re: [iOS]Call vibration

Postby Lena » Mon Oct 17, 2016 11:12 am

I got the vibration in iOS:
1. Use rlebeau code:
Code: Select all
unit UVibrate;
 
interface
 
procedure Vibrate;
 
implementation
 
{$IFDEF ANDROID}
uses
  Androidapi.JNI.Os,
  Androidapi.JNI.GraphicsContentViewText,
  Androidapi.Helpers,
  Androidapi.JNIBridge;
{$ENDIF}
{$IFDEF IOS}
uses
  IOSapi.MediaPlayer,
  IOSapi.CoreGraphics,
  FMX.Platform,
  FMX.Platform.IOS,
  IOSapi.UIKit,
  Macapi.ObjCRuntime,
  Macapi.ObjectiveC,
  iOSapi.Cocoatypes,
  Macapi.CoreFoundation,
  iOSapi.Foundation,
  iOSapi.CoreImage,
  iOSapi.QuartzCore,
  iOSapi.CoreData;
{$ENDIF}
 
{$IFDEF IOS}
const
  libAudioToolbox = '/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox';
  kSystemSoundID_vibrate = $FFF;
 
procedure AudioServicesPlaySystemSound( inSystemSoundID: integer ); cdecl;
External libAudioToolbox Name _PU + 'AudioServicesPlaySystemSound';
{$ENDIF}
 
procedure Vibrate;
{$IFDEF ANDROID}
var
  Vibrator: JVibrator;
{$ENDIF}
begin
{$IFDEF ANDROID}
  Vibrator := TJVibrator.Wrap((SharedActivityContext.getSystemService(TJContext.JavaClass.VIBRATOR_SERVICE)
as ILocalObject).GetObjectID);
  // Vibrate for 500 milliseconds
  Vibrator.vibrate(500);
{$ENDIF}
{$IFDEF IOS}
  AudioServicesPlaySystemSound( kSystemSoundID_vibrate );
{$ENDIF}
end;
 
end.


2. Add path. See picture.
Tools->Options->SDK Manager->click Add the new path item.

3.
Code: Select all
#include "UVibrate.hpp";
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    Vibrate();
}
Attachments
pic.jpg
pic.jpg (50.23 KiB) Viewed 2985 times
Lena
BCBJ Master
BCBJ Master
 
Posts: 454
Joined: Sun Feb 06, 2011 1:28 pm

Re: [iOS]Call vibration

Postby Lena » Tue Oct 18, 2016 1:32 am

Hi.
How to upgrade the procedure Vibrate to be able to call or vibration or sound notifications?
Thank you.
Lena
BCBJ Master
BCBJ Master
 
Posts: 454
Joined: Sun Feb 06, 2011 1:28 pm


Return to Technical

Who is online

Users browsing this forum: Bing [Bot] and 10 guests

cron