Latest 0.1.1
Homepage https://github.com/alexruperez/SafeBrowsing
License MIT
Platforms ios 8.0
Authors

Twitter
Version
License
Platform
Swift
Carthage compatible
Swift Package Manager Compatible
Build Status
codecov

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

SafeBrowsing

🌟 Features

  • [x] Check multiple URLs asynchronously
  • [x] Check single URL asynchronously
  • [x] Check single URL synchronously
  • [x] Open URL in Safari only if it’s safe
  • [x] UIApplication extension

📲 Installation

SafeBrowsing is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SafeBrowsing'

Or you can install it with Carthage:

github "alexruperez/SafeBrowsing"

Or install it with Swift Package Manager:

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

🛠 Configuration

Required configuration

Just enable Google Safe Browsing API and get your API key.

SafeBrowsing.apiKey = "YOUR_API_KEY_HERE"

Advanced optional configuration

You can easily customize threat types, platform types or threat 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, error in
    // Your code here
}

Check single URL asynchronously:

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

Check single URL synchronously:

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

Open URL in Safari only if it’s safe:

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

UIApplication extension

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

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

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

Testing Google Safe Browsing

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

❤️ Etc.

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

👨‍💻 Authors

alexruperez, [email protected]

👮‍♂️ License

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

Latest podspec

{
    "name": "SafeBrowsing",
    "version": "0.1.1",
    "summary": "Protect your users against malware and phishing threats using Google Safe Browsing",
    "homepage": "https://github.com/alexruperez/SafeBrowsing",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Alex Rupu00e9rez": "[email protected]"
    },
    "source": {
        "git": "https://github.com/alexruperez/SafeBrowsing.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/alexruperez",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SafeBrowsing/*.{h,swift}"
}

Pin It on Pinterest

Share This