Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Protect your users against malware and phishing threats using Google Safe Browsing

License

NotificationsYou must be signed in to change notification settings

alexruperez/SafeBrowsing

Repository files navigation

TwitterVersionLicensePlatformSwiftCarthage compatibleSwift Package Manager CompatibleBuild Statuscodecov

Protect your users against malware and phishing threats using Google Safe Browsing

SafeBrowsing

🌟 Features

  • Check multiple URLs asynchronously
  • Check single URL asynchronously
  • Check single URL synchronously
  • Open URL in Safari only if it's safe
  • UIApplication extension
  • UIViewController extension
  • SFSafariViewController compatible

📲 Installation

SafeBrowsing is available throughCocoaPods. To installit, simply add the following line to your Podfile:

pod'SafeBrowsing'

Or you can install it withCarthage:

github "alexruperez/SafeBrowsing"

Or install it withSwift Package Manager:

dependencies:[.package(url:"https://github.com/alexruperez/SafeBrowsing.git", from:"0.1.0")]

🛠 Configuration

Required configuration

Justenable Google Safe Browsing API andget your API key.

SafeBrowsing.apiKey="YOUR_API_KEY_HERE"

Advanced optional configuration

You can easily customizethreat types,platform types orthreat entry types.

SafeBrowsing.clientId="YOUR_CLIENT_ID" // By default your bundle identifier.SafeBrowsing.clientVersion="YOUR_CLIENT_VERSION" // By default your bundle short version.SafeBrowsing.threatTypes=[.malware,.socialEngineering,.unwantedSoftware,.potenciallyHarmfulApplication]SafeBrowsing.platformTypes=[.any]SafeBrowsing.threatEntryTypes=[.url,.executable]

🐒 Usage

Check multiple URLs asynchronously:

SafeBrowsing.isSafe([anURL, anotherURL]){ isSafe, errorin    // Your code here}

Check single URL asynchronously:

SafeBrowsing.isSafe(anURL){ isSafe, errorin    // Your code here}

Check single URL synchronously:

Caution: Don't call it in main thread
ifSafeBrowsing.isSafe(anURL){    // Your code here}

Open URL in Safari only if it's safe:

SafeBrowsing.safeOpen(anURL){ opened, errorin    // Your code here}

Open URL in SFSafariViewController only if it's safe:

SafeBrowsing.safeOpenInSafariViewController(anURL, over: aViewController, animated:true){ opened, errorin    // Your code here}

UIApplication extension

Yes, you can use SafeBrowsing with UIApplication, just likeopen(_:options:completionHandler:) method works.

You also have all isSafe(_:) methods available with this extension.

UIApplication.shared.safeOpen(anURL){ opened, errorin    // Your code here}

Open URL in SFSafariViewController only if it's safe:

UIApplication.shared.safeOpenInSafariViewController(anURL, over: aViewController, animated:true){ opened, errorin    // Your code here}

UIViewController extension

aViewController.safeOpenInSafariViewController(anURL, animated:true){ opened, errorin    // Your code here}

Testing Google Safe Browsing

lettestingURL=URL(string:"http://malware.testing.google.test/testing/malware/")!SafeBrowsing.isSafe(testingURL){ isSafe, errorinprint(error.debugDescription)}

❤️ Etc.

  • Contributions are very welcome.
  • Attribution is appreciated (let's spread the word!), but not mandatory.

👨‍💻 Authors

alexruperez,contact@alexruperez.com

👮‍♂️ License

SafeBrowsing is available under the MIT license. See the LICENSE file for more info.


[8]ページ先頭

©2009-2025 Movatter.jp