Skip to content

Commit

Permalink
Merge pull request #39 from capacitor-community/appcenter-lint-error
Browse files Browse the repository at this point in the history
appcenter linting and cross ref dependency fix
  • Loading branch information
johnborges authored Oct 6, 2021
2 parents ce1290b + 57fef74 commit 2b81cf3
Show file tree
Hide file tree
Showing 23 changed files with 212 additions and 164 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = 'AppCenterCapacitorShared'
s.version = '0.1.0'
s.version = '0.3.5'
s.summary = 'Shared utility to assist with bootstrapping AppCenter for Capacitor plugin.'
s.homepage = 'https://github.com/capacitor-community/appcenter-sdk-capacitor'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'johnborges' => '[email protected]' }
s.source = { :http => 'https://github.com/capacitor-community/appcenter-sdk-capacitor/releases/download/0.1.0/AppCenter-SDK-Capacitor-iOS-Pod-0.1.0.zip' }
s.source = { :git => 'https://github.com/capacitor-community/appcenter-sdk-capacitor.git' , :tag => "AppCenter-SDK-Capacitor-iOS-Pod-#{s.version}" }
s.social_media_url = 'https://twitter.com/johnborges'
s.ios.deployment_target = '12.0'
s.swift_version = '5.1'
s.source_files = '*.swift'
s.dependency 'AppCenter/Core', '4.1.1'
s.source_files = 'AppCenterCapacitorShared/ios/AppCenterCapacitorShared/*.swift'
s.dependency 'AppCenter/Core', '4.3.0'
s.static_framework = true
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,89 @@ import Foundation
import AppCenter

public class AppCenterCapacitorShared: NSObject {

static var startAutomatically: Bool = true
static var configuration: NSDictionary = [:]
static var appSecret: String?
static var logLevel: UInt?
static var wrapperSdk: WrapperSdk?
// plist keys
static var kAppCenterSecretKey = "AppSecret"
static var kAppCenterStartAutomaticallyKey = "StartAutomatically"
static var kAppCenterLogLevelKey = "LogLevel"
static var kAppCenterConfigResource = "AppCenter-Config"


public static func isSdkConfigured() -> Bool {
return AppCenter.isConfigured
}

public static func getConfiguration() -> NSDictionary {
return configuration
}

public static func setStartAutomatically (_ shouldStartAutomatically: Bool) {
startAutomatically = shouldStartAutomatically;
startAutomatically = shouldStartAutomatically
}

public static func configureWithSettings() {
if AppCenter.isConfigured {
return
}

let wrapperSdk = WrapperSdk(wrapperSdkVersion: "0.1.0", wrapperSdkName: "appcenter.capacitor", wrapperRuntimeVersion: nil, liveUpdateReleaseLabel: nil, liveUpdateDeploymentKey: nil, liveUpdatePackageHash: nil)

setWrapperSdk(wrapperSdk!)
getAppSecret()

let tempWrapperSdk = WrapperSdk(wrapperSdkVersion: "0.3.5",
wrapperSdkName: "appcenter.capacitor",
wrapperRuntimeVersion: nil,
liveUpdateReleaseLabel: nil,
liveUpdateDeploymentKey: nil,
liveUpdatePackageHash: nil)

if let actualWrapperSdk = tempWrapperSdk {
setWrapperSdk(actualWrapperSdk)
}
getSdkConfig()

if startAutomatically {
if appSecret!.count == 0 {
if let actualSecret = appSecret, actualSecret.count != 0 {
AppCenter.configure(withAppSecret: actualSecret)
} else {
AppCenter.configure()
}
else {
AppCenter.configure(withAppSecret: appSecret)

// set log level if specified
if let actualLogLevel = logLevel {
AppCenter.logLevel = LogLevel.init(rawValue: actualLogLevel) ?? .assert
}
}
}

public static func setAppSecret(_ secret: String) {
appSecret = secret
}
public static func getAppSecret() {

public static func getSdkConfig() {
if appSecret == nil {
// get values from config plist
let plist = Bundle.main.path(forResource: AppCenterCapacitorShared.kAppCenterConfigResource, ofType: "plist")
configuration = NSDictionary(contentsOfFile: plist!)!
appSecret = configuration[AppCenterCapacitorShared.kAppCenterSecretKey] as? String

// start automatically flag true by default
if let rawStartAutomatically = configuration[AppCenterCapacitorShared.kAppCenterStartAutomaticallyKey] as? Bool {
startAutomatically = rawStartAutomatically
// get config plist
if let plist = Bundle.main.path(forResource: AppCenterCapacitorShared.kAppCenterConfigResource, ofType: "plist") {
configuration = NSDictionary(contentsOfFile: plist) ?? [:]

// get appSecret key
appSecret = configuration[AppCenterCapacitorShared.kAppCenterSecretKey] as? String

// get log level
logLevel = configuration[AppCenterCapacitorShared.kAppCenterLogLevelKey] as? UInt

// start automatically flag true by default
if let rawStartAutomatically = configuration[AppCenterCapacitorShared.kAppCenterStartAutomaticallyKey] as? Bool {
startAutomatically = rawStartAutomatically
}
}
}
}

public static func getWrapperSdk() -> WrapperSdk? {
return wrapperSdk
}

public static func setWrapperSdk(_ sdk: WrapperSdk) {
wrapperSdk = sdk
AppCenter.wrapperSdk = sdk
Expand Down
15 changes: 13 additions & 2 deletions AppCenterCapacitorShared/ios/AppCenterCapacitorShared/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# AppCenterCapacitorShared

[![CI Status](https://img.shields.io/travis/johnborges/AppCenterCapacitorShared.svg?style=flat)](https://travis-ci.org/johnborges/AppCenterCapacitorShared)
[![Version](https://img.shields.io/cocoapods/v/AppCenterCapacitorShared.svg?style=flat)](https://cocoapods.org/pods/AppCenterCapacitorShared)
[![License](https://img.shields.io/cocoapods/l/AppCenterCapacitorShared.svg?style=flat)](https://cocoapods.org/pods/AppCenterCapacitorShared)
[![Platform](https://img.shields.io/cocoapods/p/AppCenterCapacitorShared.svg?style=flat)](https://cocoapods.org/pods/AppCenterCapacitorShared)

This pod is meant to be a helper utility for App Center Capacitor Plugins.

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements

## Installation

Expand All @@ -20,6 +20,17 @@ it, simply add the following line to your Podfile:
pod 'AppCenterCapacitorShared'
```

## Linting
local linting
```bash
pod lib lint
```

against spec repo
```bash
pod spec lint
```

## Author

johnborges, [email protected]
Expand Down
7 changes: 7 additions & 0 deletions appcenter-analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [0.3.2](https://github.com/capacitor-community/appcenter-sdk-capacitor/compare/@capacitor-community/[email protected]...@capacitor-community/[email protected])

### Fixes

* **ios**
* Update `AppCenterCapacitorShared` to 0.3.5 and using optimistic operator

## 0.3.1

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '12.0'
s.dependency 'Capacitor'
s.dependency 'AppCenterCapacitorShared', '0.3.2'
s.dependency 'AppCenterCapacitorShared', '~> 0.3.5'
s.dependency 'AppCenter/Analytics', '4.3.0'
s.static_framework = true
s.swift_version = '5.1'
Expand Down
2 changes: 1 addition & 1 deletion appcenter-analytics/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

target 'Plugin' do
capacitor_pods
pod 'AppCenterCapacitorShared', '0.3.2'
pod 'AppCenterCapacitorShared', '~> 0.3.5'
pod 'AppCenter/Analytics', '4.3.0'
end

Expand Down
2 changes: 1 addition & 1 deletion appcenter-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor-community/appcenter-analytics",
"version": "0.3.1",
"version": "0.3.2",
"description": "Capacitor plugin for AppCenter Analytics",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
7 changes: 7 additions & 0 deletions appcenter-crashes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [0.7.1](https://github.com/capacitor-community/appcenter-sdk-capacitor/compare/@capacitor-community/[email protected]...@capacitor-community/[email protected])

### Fixes

* **ios**
* Update `AppCenterCapacitorShared` to 0.3.5 and using optimistic operator

## 0.7.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Pod::Spec.new do |s|
s.swift_version = '5.1'
s.static_framework = true
s.dependency 'Capacitor'
s.dependency 'AppCenterCapacitorShared', '0.3.2'
s.dependency 'AppCenterCapacitorShared', '~> 0.3.5'
s.dependency 'AppCenter/Crashes', '4.3.0'
end
2 changes: 1 addition & 1 deletion appcenter-crashes/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

target 'Plugin' do
capacitor_pods
pod 'AppCenterCapacitorShared', '0.3.2'
pod 'AppCenterCapacitorShared', '~> 0.3.5'
pod 'AppCenter/Crashes', '4.3.0'
end

Expand Down
2 changes: 1 addition & 1 deletion appcenter-crashes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor-community/appcenter-crashes",
"version": "0.7.0",
"version": "0.7.1",
"description": "Capacitor plugin for Microsoft's App Center Crashes",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
6 changes: 6 additions & 0 deletions appcenter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [0.7.2](https://github.com/capacitor-community/appcenter-sdk-capacitor/compare/@capacitor-community/[email protected]...@capacitor-community/[email protected])

### Chores

* **ios**: Bump `AppCenterCapacitorShared` version to `0.3.5`

## [0.7.1](https://github.com/capacitor-community/appcenter-sdk-capacitor/compare/@capacitor-community/[email protected]...@capacitor-community/[email protected])

### Chores
Expand Down
2 changes: 1 addition & 1 deletion appcenter/CapacitorCommunityAppcenter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '12.0'
s.dependency 'Capacitor'
s.dependency 'AppCenterCapacitorShared', '0.3.2'
s.dependency 'AppCenterCapacitorShared', '~> 0.3.5'
s.static_framework = true
s.swift_version = '5.1'
end
4 changes: 2 additions & 2 deletions appcenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Toggle all App Center services at runtime. When disabled, the SDK won't forward
setCustomProperties(options: { properties: CustomProperties; }) => any
```

App Center allows you to define custom properties as key value pairs in your app. You may use custom properties for various purposes.
App Center allows you to define custom properties as key value pairs in your app. You may use custom properties for various purposes.
For instance, you can use custom properties to segment your users, and then send push notifications to a specific audience.

| Param | Type |
Expand Down Expand Up @@ -207,7 +207,7 @@ setLogLevel(options: { logLevel: LogLevel; }) => any
```

You can control the amount of log messages that show up from App Center in the console. Log messages show in the console on iOS and LogCat on Android.
By default, it's set to Assert for the App Store environment and Warning otherwise. To have as many log messages as possible, use Verbose.
By default, it's set to Assert for the App Store environment and Warning otherwise. To have as many log messages as possible, use Verbose.
Note: `setLogLevel` API can't increase logging for app startup code, before JavaScript is loaded.

| Param | Type |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.getcapacitor.plugin.appcenter;

import java.util.UUID;
import java.util.Iterator;

import org.json.JSONObject;
import java.util.Date;

import com.getcapacitor.JSObject;

import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.CustomProperties;
import java.util.Date;
import java.util.Iterator;
import java.util.UUID;
import org.json.JSONObject;

public class AppCenterBase {

Expand Down Expand Up @@ -65,28 +62,22 @@ public void setCustomProperties(JSObject properties) {
case "clear":
customProps.clear(key);
break;

case "string":
customProps.set(key, valueObject.getString("value"));
break;

case "number":
customProps.set(key, Double.parseDouble(valueObject.getString("value")));
break;

case "boolean":
customProps.set(key, valueObject.getBool("value"));
break;

case "date-time":
customProps.set(key, new Date((long) Double.parseDouble(valueObject.getString("value"))));
break;
}

}
}


AppCenter.setCustomProperties(customProps);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.annotation.CapacitorPlugin;

import com.microsoft.appcenter.reactnative.shared.AppCenterReactNativeShared;

@CapacitorPlugin(name = "AppCenter")
Expand All @@ -19,14 +18,14 @@ public class AppCenterPlugin extends Plugin {
public void load() {
AppCenterReactNativeShared.configureAppCenter(this.getActivity().getApplication());
}

@PluginMethod
public void getInstallId(PluginCall call) {
JSObject ret = new JSObject();
ret.put("value", implementation.getInstallId());
call.resolve(ret);
}

@PluginMethod(returnType = PluginMethod.RETURN_NONE)
public void setUserId(PluginCall call) {
implementation.setUserId(call.getString("userId", null));
Expand Down
Loading

0 comments on commit 2b81cf3

Please sign in to comment.