This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Where the preferences are stored on the system | |
*/ | |
private val preferencesFile: String | |
get() = "${this::class.java.simpleName}.prefs" | |
/** | |
* The name of the custom attribute | |
*/ | |
private val categoriesAttributeName = "categories" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Record a successful authentication | |
* | |
* @param username the username of the user that was authenticated | |
*/ | |
override fun recordSuccessfulLogin(username: String) { | |
// Update the endpoint profile to include the username | |
val profile = pinpoint.targetingClient.currentEndpoint() | |
profile.user.userId = username | |
pinpoint.targetingClient.updateEndpointProfile(profile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import com.amazonaws.mobile.auth.core.IdentityManager | |
import com.amazonaws.mobile.config.AWSConfiguration | |
import com.amazonaws.mobile.samples.picturefeed.services.AnalyticsService | |
import com.amazonaws.mobileconnectors.pinpoint.PinpointConfiguration | |
import com.amazonaws.mobileconnectors.pinpoint.PinpointManager | |
class AWSAnalyticsService(context: Context): AnalyticsService { | |
private var manager: PinpointManager? = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.INTERNET"/> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation 'com.amazonaws:aws-android-sdk-pinpoint:2.6.27' | |
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.6.27@aar') { transitive = true } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocalAnalyticsService : AnalyticsService { | |
override fun recordEvent(eventName: String, attributes: Map<String,String>?, metrics: Map<String,Double>?) { | |
val event = StringBuilder("") | |
attributes?.let { | |
for ((k, v) in it) { event.append(", $k=\"$v\"") } | |
} | |
metrics?.let { | |
for ((k, v) in it) { event.append(", $k=${String.format("%.2f",v)}") } | |
} | |
if (event.isNotEmpty()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface AnalyticsService { | |
fun recordEvent(eventName: String, attributes: Map<String,String>? = null, metrics: Map<String,Double>? = null) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import AWSCore | |
import AWSPinpoint | |
class AWSAnalyticsService : AnalyticsService { | |
var pinpoint: AWSPinpoint? | |
init() { | |
let config = AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: nil) | |
pinpoint = AWSPinpoint(configuration: config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
target 'MyNotes' do | |
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks | |
use_frameworks! | |
# Analytics dependency | |
pod 'AWSPinpoint' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MasterViewController: UITableViewController { | |
var analyticsService: AnalyticsService? = nil | |
override func viewDidLoad() { | |
super.viewDidLOad() | |
analyticsService = (UIApplication.shared.delegate as! AppDelegate).analyticsService | |
// Rest of initialization here | |
// Record the view load |