2014-09-26 61 views

回答

3

沒有API,但是如果您啓用了應用程序組訪問權限,則可以嘗試檢查您是否可以讀取/寫入文件夾。它應該給你一個權限錯誤訪問未啓用。

2

使用此,

-(BOOL)isOpenAccessGranted 
{ 
     NSFileManager *filemanager = [NSFileManager defaultManager]; 
     NSString *containerPath = [[filemanager containerURLForSecurityApplicationGroupIdentifier:@"/***YOUR APP GROUP ID***/"] path]; 

     NSError *err; 

     [filemanager contentsOfDirectoryAtPath:containerPath error:&err]; 

     if(err != nil) 
     { 
      NSLog(@"Full Access: Off"); 
      return NO; 
     } 

     NSLog(@"Full Access On"); 
     return YES; 
} 
+0

一些細節:http://stackoverflow.com/questions/25472388/how-to-check-the -allow-full-access-is-enabled-in-ios-8 – fisch2 2014-11-20 23:05:42

5

我覺得這是一個簡單的方法(無需創建一個容器):

- (BOOL) isOpenAccessGranted 
{ 
    if ([UIPasteboard generalPasteboard]) 
     return YES; 

    return NO; 
} 
0
在iOS10測試

紙板API改變

斯威夫特:

func isOpenAccessGranted() -> Bool { 
    let originalString = UIPasteboard.general.string 
    UIPasteboard.general.string = "TEST" 
    if UIPasteboard.general.hasStrings { 
     UIPasteboard.general.string = originalString 
     return true 
    }else{ 
     return false 
    } 
} 

找到這裏

How to check the "Allow Full Access" is enabled in iOS 8?

這節省現場回答我測試了幾個應用程序和完美的作品!

+0

downvote的任何理由?如果這裏有什麼問題,如果你能解釋的話,會很好。 – 2016-09-06 17:50:39

+0

好像是在爲我工作:) – Drico 2016-09-07 14:24:43

+0

awesome,@Drico – 2016-09-07 14:33:40

0

您可以使用此功能來檢查你的自定義鍵盤延長有開放接入與否:

func isOpenAccessGranted() -> Bool{ 
    if #available(iOS 10.0, *) { 
     let originalString = UIPasteboard.general.string 
     UIPasteboard.general.string = "Sour LeangChhean" 

     if UIPasteboard.general.hasStrings { 

      UIPasteboard.general.string = originalString ?? "" 
      return true 
     }else{ 
      UIPasteboard.general.string = "" 
      return false 
     } 
    } else { 
    // Fallback on earlier versions 
     if UIPasteboard.general.isKind(of: UIPasteboard.self) { 
      return true 
     }else{ 
      return false 
     } 
    } 
} 
相關問題