With the Orange trust badge, aka "Badge de confiance", give transparent informations and user control on personal data and help users to identify if your application has any sensitive features.
Orange trust badge displays how are handled the following device permissions :
- Location
- Contacts
- Photos Library
- Media
- Camera
- Calendar
- Reminders
- Bluetooth Sharing
- Microphone
- Speech Recognition
- Health
- Homekit
- Motion Activity & Fitness
It can also displays the following application data :
- Notifications
- Identity
- Account Informations
- Data usage
- Advertising
- History
It also :
- Works on iPhone and iPad using Autolayout (iPad Multitasking supported)
- Localized in 2 languages (English, French)
- Written in Swift 5.0 but works in Objective-C or Swift based Projects
- API hooks
- UI Customization
- iOS 9.0+
- Xcode 10.2.1+
- CocoaPods 1.6.1+
- If you find any bugs, please submit a bug report through Github and/or a pull request.
An example of integration is provided in OrangeTrustBadgeDemo project.
Embedded frameworks require a minimum deployment target of iOS 8
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.0.1+ is required to build OrangeTrustBadge.
To integrate OrangeTrustBadge into your Xcode project using CocoaPods, specify it in your Podfile
:
platform :ios, '9.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
pod 'OrangeTrustBadge'
In a post_install directive of your Podfile configure the OTHER_SWIFT_FLAGS with ONLY what your app need. See the table in the section named Configure OrangeTrustBage build.
eg: If your app needs the HealthKit permission add the line
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DHEALTHKIT'
if not, DO NOT ADD IT.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DCORELOCATION'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DCONTACTS'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DPHOTOS'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DMEDIAPLAYER'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DCAMERA'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DEVENTKIT'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DBLUETOOTH'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DMICROPHONE'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DSPEECH'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DUSERNOTIFICATIONS'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DMOTION'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DHEALTHKIT'
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DHOMEKIT'
end
end
end
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate OrangeTrustBadge into your Xcode project using Carthage, specify it in your Cartfile:
github "Orange-OpenSource/orange-trust-badge-ios" ~> 1.1
Run the following commands to configure then build the framework. Drag the built OrangeTrustBadge.framework into your Xcode project.
$ carthage checkout orange-trust-badge-ios
$ cd Carthage/Checkouts/orange-trust-badge-ios/
$ ./Scripts/configure.sh
$ cd -
$ carthage build orange-trust-badge-ios
In order to pass the App Store validation, you must declare only the permissions that your app effectively use. Otherwise Apple may reject your app.
So OrangeTrustBadge compiles and uses only the needed frameworks by setting the OTHER_SWIFT_FLAGS build setting.
COMPILE FLAG | FRAMEWORK | PERMISSION |
---|---|---|
CORELOCATION | CoreLocation | Location |
PHOTOS | Photos | Photos |
CONTACTS | Contacts | Contacts |
MEDIAPLAYER | MediaPlayer | Media |
CAMERA | MediaPlayer | Camera |
EVENTKIT | EventKit | Calendar, Reminders |
BLUETOOTH | CoreBluetooth | Bluetooth Sharing |
MICROPHONE | AVFoundation | Microphone |
SPEECH | Speech | Speech Recognition |
USERNOTIFICATIONS | UserNotifications | Notifications |
MOTION | CoreMotion | Motion Activity & Fitness |
HEALTHKIT | HeakthKit | HealthKit |
HOMEKIT | HomeKit | HomeKit |
If you use Cocoapods, use a post_install directive to configure the badge. See the section Cocoapods above.
If you use Carthage, The script name configure.sh provided with OrangeTrustBadge will be automaticaly configured the framework. What you have defined in the InfoPlist.strings of your project will be used to set the OTHER_SWIFT_FLAGS build setting with the right values.
eg: If you define NSContactsUsageDescription in the InfoPlist.strings of your project then OrangeTrustBadge will add the flag -DCONTACTS
in the OTHER_SWIFT_FLAGS build setting.
See the section Carthage above.
Here is an example of what your app InfoPlist.string file would look like.
"NSSpeechRecognitionUsageDescription" = "This application has requested access to speech recognition. Speech recognition sends recorded voice to Apple to process your requests.";
"NSAppleMusicUsageDescription" = "This application has requested access to your music activity and your media library.";
"NSBluetoothPeripheralUsageDescription" = "This application has the ability to share data via Bluetooth.";
"NSCalendarsUsageDescription" = "This application can use the calendar information on your device, including consultation of recorded events.";
"NSCameraUsageDescription" = "This application can use the camera of your device. The camera access allows this application to take pictures and record video.";
"NSContactsUsageDescription" = "This application can access, add and / or change your phone contacts.";
"NSHealthShareUsageDescription" = "This application has requested access to your health data.";
"NSHealthUpdateUsageDescription" = "This application has requested access to your health data.";
"NSHomeKitUsageDescription" = "This application has requested access to your home data.";
"NSLocationAlwaysAndWhenInUseUsageDescription" = "With your permission, Location Services allows this application to use information from cellular, Wi-Fi, Global Positioning System (GPS) networks, and Bluetooth to determine your approximate location.";
"NSLocationAlwaysUsageDescription" = "With your permission, Location Services allows this application to use information from cellular, Wi-Fi, Global Positioning System (GPS) networks, and Bluetooth to determine your approximate location.";
"NSLocationWhenInUseUsageDescription" = "With your permission, Location Services allows this application to use information from cellular, Wi-Fi, Global Positioning System (GPS) networks, and Bluetooth to determine your approximate location.";
"NSMicrophoneUsageDescription" = "This application can use the microphone of your device. The access to micro allows the application to record audio content.";
"NSMotionUsageDescription" = "Fitness and health tracking allows apps to access sensor data, including body movement, steps count, and more.";
"NSPhotoLibraryUsageDescription" = "This application can use photos stored on your device. This permission allows the application to read, edit or delete stored files.";
"NSRemindersUsageDescription" = "This application can use the reminders information on your device, including consultation of recorded events.";
In swift
import OrangeTrustBadge
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
TrustBadge.with(TrustBadgeConfig())
return true
}
or in Objective-C
#import "OrangeTrustBadge-Swift.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[TrustBadge with:[[TrustBadgeConfig alloc] init]];
return YES;
}
- Create an IBAction connected to one of your interface element (e.g a button, a cell etc...).
- Instanciate OrangeTrustBadge storyboard with the following lines :
Present the badge modally
import OrangeTrustBadge
@IBAction func presentBadge(sender: Any?) {
if let viewController = storyboard.instantiateInitialViewController() as? UISplitViewController {
viewController.modalPresentationStyle = .fullScreen
self.present(viewController, animated: true, completion: nil)
// Uncomment this section if you want change the navigationBar Appearance
// and adopt a status bar style (.lightContent or .default)
let navigationController = viewController.viewControllers[0] as! UINavigationController
navigationController.navigationBar.setAppearance(for: UIStatusBarStyle.lightContent)
}
}
Push the badge
import OrangeTrustBadge
@IBAction func pushBadge(sender: Any?) {
let viewController = storyboard.instantiateViewController(withIdentifier: "LandingController")
self.navigationController?.pushViewController(viewController, animated: true)
// Uncomment this section if you want change the navigationBar Appearance
// and adopt a status bar style (.lightContent or .default)
self.navigationController?.navigationBar.setAppearance(for: UIStatusBarStyle.lightContent)
}
Setting up the navigationBar and the statusBar appearance
extension UINavigationBar {
func setAppearance(for statusBarStyle: UIStatusBarStyle) {
// remove the shadow image at the bottom of the navbar
setBackgroundImage(UIImage(), for: .default)
shadowImage = UIImage()
var darkMode = false
if #available(iOS 12.0, *) {
darkMode = traitCollection.userInterfaceStyle == .dark
}
// for lightContent
switch statusBarStyle {
case .default where darkMode == true:
titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
barTintColor = nil
tintColor = .white
barStyle = .black
case .default:
titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
barTintColor = UIColor(red: 57/255, green: 176/255, blue: 168/255, alpha: 1)
tintColor = .black
barStyle = .default
case .lightContent:
titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
barTintColor = nil
tintColor = .white
barStyle = .black
case .darkContent:
titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
barTintColor = UIColor(red: 57/255, green: 176/255, blue: 168/255, alpha: 1)
tintColor = .black
barStyle = .default
@unknown default:
break
}
}
}
That's it !
- Open your storyboard file and add a Storyboard reference object in it
- Click on newly created Storyboard Reference and go into Attribute inspector on the right panel
- In Storyboard field, select
OrangeTrustBadge
- In Bundle field, type
org.cocoapods.OrangeTrustBadge
- Finally, create a segue from the appropriate button or cell in your app and this Storyboard Reference (Some segue types might be unavailable since this component is using UISplitViewController - Try "Present Modally" to start)
That's it !
You may have to add some informations related to your app in the badge section. Orange Trust Badge allow you to provide a view controller wich will be displayed as a custom view.
To provide this view controller, you must implement two methods of TrustBadgeDelegate
protocol.
/// If this method returns true, the landing page will displayed a cell that allows to access
//// to this view controller.
@objc optional func shouldDisplayCustomViewController() -> Bool
/// Implement this method to return a viewController to displayed for the CustomMenuCell
@objc optional func viewController(at indexPath: IndexPath) -> UIViewController
To allow the user to access you custom view controller, TrustBadge will add a an entry in LandingController. The title and the subtitle of this entry (UITableViewCell) must be configured with the following Localizable.string keys.
Title
"landing-custom-title" = "Customizable content";
Subtitle
"landing-custom-content" = "Find out other apps that have adopted the Trust Badge";
In order to localize properly the UI, OrangeTrustBadge is using standard iOS mechanisms. Concretly the SDK will take the current language setup on user's phone unless your app support this localization. English will be taken by Default.
To add a localization support, go to Project Level and add appropriate localization in "Info" Tab.
You can override every visible text using your own Localizable.strings file. To know which key you need to override, please see SDK 's Localization file.
OrangeTrustBadge can be customized in various ways
In this View are displayed two pre-defined sections showing TrustBadge Elements and their underlying status. Although it is required to have at least one item in the first section, you can fully customize the different sections using PreDefined or Custom Elements.
- A PreDefinedElement that is automagically setup for common cases
Note: If desired, you will be able to also customize the behavior of PreDefinedElements. Be sure to disengage automatic setup by setting the property shouldBeAutoConfigured to false. (e.g : aPreDefinedElement.shouldBeAutoConfigured = false)
In swift
let advertisingElement = PreDefinedElement(type: .advertising)
advertisingElement.statusClosure = {() in return true}
config.applicationData.append(advertisingElement)
In this section you will find Standardized Terms ans conditions that can be replaced / updated according to your needs through Localization. If you want to add a section in this View, you just have to add a new Term instance :
In swift
let customTerm = Term(type: .Custom, titleKey: "term-custom-title", contentKey: "term-custom-content")
config.terms.append(customTerm)
You can even display Dailymotion videos explaining your policies using .Video TermType. Please fill in "contentKey" with the video ID from Dailymotion (ex: x3xwu6v ).
TrustBadgeElements and Terms descriptions may contains HTML code, with the following restriction :
- UTF-8 encoded
- no external resource (image, css, ...) can be used
When HTML is possible, there are 2 cases
- Full HTML : you must provide a HTML code WITH
<html>
and<body>
tags - Partial HTML : you must provide a HTML code WITHOUT
<html>
and<body>
tags
Descriptions should include a stylesheet named <span class="p">
.
You can provide to OrangeTrustBadge your own CSS file by placing a file named style.css in your application bundle.
In HTML
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<style type="text/css">$$cssStylesheet$$</style>
</meta>
</head>
<body>
<h1>Aide</h1>
<p>Si besoin, votre application met à disposition cette adresse mail pour répondre à vos questions :</p>
<span class="p">
<!-- span.p is used for last paragraph, otherwise layount is broken-->
[email protected]
</span>
</body>
</html>
Some tokens will be available over time, but for the moment you can only use
OrangeTrustBadge is not requesting anything on the network unless you include videos in the Terms section. Videos are hosted on Dailymotion.com and connections made to this service are compliant with ATS policies.
OrangeTrustBadge was made with love by Orange
If you believe you have identified a security vulnerability with OrangeTrustBadge, you should report it as soon as possible on the bug tracker.
OrangeTrustBadge Copyright (C) 2016 - 2019 Orange
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.