Unterstütze den Ausbau der fairapps.net Infrastruktur und Serviceangebote per Crowdfunding oder hilf mit Issues zu lösen!

Commit 719361ba authored by armin's avatar armin

os min version set to 11

parent c14008c9
Pipeline #794 passed with stage
in 2 minutes and 32 seconds
Subproject commit 1a8cb167fd08c9df87eed75e94af36a11453e48f
Subproject commit 9ab892de72db4d211e6ad93e21f6e07cef3b412f
......@@ -163,7 +163,7 @@ ios{
QMAKE_ASSET_CATALOGS = $$PWD/ios/Images.xcassets
QMAKE_ASSET_CATALOGS_APP_ICON = "Appicon"
QMAKE_IOS_DEPLOYMENT_TARGET = 10.0
QMAKE_IOS_DEPLOYMENT_TARGET = 11.0
QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 1
PRODUCT_NAME = fairchat
#PRODUCT_BUNDLE_IDENTIFIER = com.osalliance.RocketChatMobile
......
......@@ -42,6 +42,7 @@ class IosGalleryPicker: public QObject
void receiveFile( QString pFileUrl );
private:
void openGalleryPicker();
QString mImagePath;
void *mDelegate;
......
......@@ -43,16 +43,22 @@
UIImage *orig = [info valueForKey:UIImagePickerControllerOriginalImage];
PHAsset *asset = [info valueForKey:UIImagePickerControllerPHAsset];
NSString *filename = [asset valueForKey:@"filename"];
QString qFilename = QString::fromNSString(filename);
auto assetRes = [PHAssetResource assetResourcesForAsset:asset];
auto assetObj = [assetRes firstObject];
QStringList fileParts = qFilename.split(".");
QString fileExt = fileParts[fileParts.length()-1];
if(assetObj){
NSString * filename = [assetObj originalFilename ];
NSString *assetUti = [assetObj valueForKey:@"uniformTypeIdentifier"];
QString assetUtiStr = QString::fromNSString(assetUti);
QString qFilename = QString::fromNSString(filename);
NSData *imgData = nil;
if(!fileExt.compare("png",Qt::CaseInsensitive)){
if(assetUtiStr == "public.png"){
imgData = UIImagePNGRepresentation(orig);
}else{
imgData = UIImageJPEGRepresentation(orig, 1.0);
......@@ -60,12 +66,16 @@
QByteArray qImgData = QByteArray::fromNSData(imgData);
QString path = QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation );
path += "/"+QString::fromNSString(filename);
path += "/"+qFilename;
QFile destFile(path);
destFile.open(QFile::WriteOnly);
if(destFile.write(qImgData)>0){
mIosPicker->receiveFile(path);
}
}else{
qWarning()<<"failed to pick file";
}
[picker dismissViewControllerAnimated:YES completion:NULL];
[picker release];
}
......@@ -83,6 +93,28 @@ void IosGalleryPicker::receiveFile(QString pFileUrl){
void IosGalleryPicker::open()
{
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
if(status != PHAuthorizationStatusAuthorized){
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){
switch (status) {
case PHAuthorizationStatusAuthorized:
openGalleryPicker();
break;
case PHAuthorizationStatusRestricted:
break;
case PHAuthorizationStatusDenied:
break;
default:
break;
}
}];
}else{
openGalleryPicker();
}
}
void IosGalleryPicker::openGalleryPicker(){
UIViewController *qtController = [[UIApplication sharedApplication].keyWindow rootViewController];
UIImagePickerController *imageController = [[UIImagePickerController alloc] init];
......
......@@ -21,46 +21,24 @@
statusBar.backgroundColor = color;
}
if( SYSTEM_VERSION_LESS_THAN( @"9.0" ) ){
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// for iOS 8
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}else{
UIUserNotificationType myTypes = UIUserNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
}else if( SYSTEM_VERSION_LESS_THAN( @"10.0" ) )
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
if( launchOptions != nil )
{
NSLog( @"registerForPushWithOptions:" );
}
}
else
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
if( !error && granted )
{
if( !error )
{
[[UIApplication sharedApplication] registerForRemoteNotifications]; // required to get the app to do anything at all about push notifications
NSLog( @"Push registration success." );
}
else
{
NSLog( @"Push registration FAILED" );
NSLog( @"ERROR: %@ - %@", error.localizedFailureReason, error.localizedDescription );
NSLog( @"SUGGESTIONS: %@ - %@", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );
}
}];
}
[[UIApplication sharedApplication] registerForRemoteNotifications]; // required to get the app to do anything at all about push notifications
NSLog( @"Push registration success." );
}
else
{
NSLog( @"Push registration FAILED" );
NSLog( @"ERROR: %@ - %@", error.localizedFailureReason, error.localizedDescription );
NSLog( @"SUGGESTIONS: %@ - %@", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );
}
}];
volatile NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment