Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions FirebaseMessaging.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ device, and it is completely free.

base_dir = "FirebaseMessaging/"
s.source_files = [
base_dir + 'Sources/**/*',
base_dir + 'Sources/LiveActivities/*.{swift,h,m}',
base_dir + 'Sources/**/*.{c,m,h}',
base_dir + 'Sources/Protogen/nanopb/*.h',
base_dir + 'Interop/*.h',
Expand All @@ -49,13 +51,17 @@ device, and it is completely free.
"#{s.module_name}_Privacy" => 'FirebaseMessaging/Sources/Resources/PrivacyInfo.xcprivacy'
}
s.library = 'sqlite3'
# s.prepare_command = <<-CMD
# echo "Bridging header has been created"
# CMD
s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'GCC_PREPROCESSOR_DEFINITIONS' =>
# for nanopb:
'PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1',
# Unit tests do library imports using repo-root relative paths.
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"',
# 'SWIFT_OBJC_BRIDGING_HEADER' => '$(PODS_TARGET_SRCROOT)/FirebaseMessaging/Sources/LiveActivities/FirebaseMessaging-Bridging-Header.h',
}
s.ios.framework = 'SystemConfiguration'
s.tvos.framework = 'SystemConfiguration'
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSSupportsLiveActivities</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
2 changes: 1 addition & 1 deletion FirebaseMessaging/Apps/AdvancedSample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ target 'AppClips' do
end

target 'SampleWatchWatchKitExtension' do
platform :watchos, '6.0'
platform :watchos, '7.0'
shared_pods
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2020 Google LLC
//
// 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.

import WidgetKit
import AppIntents

struct ConfigurationAppIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Configuration"
static var description = IntentDescription("This is an example widget.")

// An example configurable parameter.
@Parameter(title: "Favorite Emoji", default: "😃")
var favoriteEmoji: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widgetkit-extension</string>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2020 Google LLC
//
// 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.

import WidgetKit
import SwiftUI

struct Provider: AppIntentTimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date(), configuration: ConfigurationAppIntent())
}

func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry {
SimpleEntry(date: Date(), configuration: configuration)
}

func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<SimpleEntry> {
var entries: [SimpleEntry] = []

// Generate a timeline consisting of five entries an hour apart, starting from the current date.
let currentDate = Date()
for hourOffset in 0 ..< 5 {
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
let entry = SimpleEntry(date: entryDate, configuration: configuration)
entries.append(entry)
}

return Timeline(entries: entries, policy: .atEnd)
}
}

struct SimpleEntry: TimelineEntry {
let date: Date
let configuration: ConfigurationAppIntent
}

struct SampleLiveActivityEntryView : View {
var entry: Provider.Entry

var body: some View {
VStack {
Text("Time:")
Text(entry.date, style: .time)

Text("Favorite Emoji:")
Text(entry.configuration.favoriteEmoji)
}
}
}

struct SampleLiveActivity: Widget {
let kind: String = "SampleLiveActivity"

var body: some WidgetConfiguration {
AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in
SampleLiveActivityEntryView(entry: entry)
.containerBackground(.fill.tertiary, for: .widget)
}
}
}

extension ConfigurationAppIntent {
fileprivate static var smiley: ConfigurationAppIntent {
let intent = ConfigurationAppIntent()
intent.favoriteEmoji = "😀"
return intent
}

fileprivate static var starEyes: ConfigurationAppIntent {
let intent = ConfigurationAppIntent()
intent.favoriteEmoji = "🤩"
return intent
}
}

#Preview(as: .systemSmall) {
SampleLiveActivity()
} timeline: {
SimpleEntry(date: .now, configuration: .smiley)
SimpleEntry(date: .now, configuration: .starEyes)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2020 Google LLC
//
// 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.

import WidgetKit
import SwiftUI

@main
struct SampleLiveActivityBundle: WidgetBundle {
var body: some Widget {
SampleLiveActivity()
SampleLiveActivityLiveActivity()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright 2020 Google LLC
//
// 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.

import ActivityKit
import WidgetKit
import SwiftUI

struct SampleLiveActivityAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
enum LVStatus: Float, Codable, Hashable {
case started = 0
case inProgress = 1
case completed = 2

var description: String {
switch self {
case .started:
return "Your Live Activity is started!"
case .inProgress:
return "Your Live Activity is in progress!"
case .completed:
return "Your Live activity is completed!"
}
}
}

let status: LVStatus
}

// Fixed non-changing properties about your activity go here!
var lvInstanceNumber: Double
}

struct SampleLiveActivityLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: SampleLiveActivityAttributes.self) { context in
// Lock screen/banner UI goes here
VStack {
SampleLiveActivityView(context: context)
}
.activityBackgroundTint(Color.cyan)
.activitySystemActionForegroundColor(Color.black)

} dynamicIsland: { context in
DynamicIsland {
// Expanded UI goes here. Compose the expanded UI through
// various regions, like leading/trailing/center/bottom
DynamicIslandExpandedRegion(.leading) {
Text("Leading")
}
DynamicIslandExpandedRegion(.trailing) {
Text("Trailing")
}
DynamicIslandExpandedRegion(.bottom) {
Text("Bottom")
// more content
}
} compactLeading: {
Text("L")
} compactTrailing: {
Text("T")
} minimal: {
Text("M")
}
.widgetURL(URL(string: "http://www.apple.com"))
.keylineTint(Color.red)
}
}
}

extension SampleLiveActivityAttributes {
fileprivate static var preview: SampleLiveActivityAttributes {
SampleLiveActivityAttributes(lvInstanceNumber: 1)
}
}

extension SampleLiveActivityAttributes.ContentState {
fileprivate static var stateStarted: SampleLiveActivityAttributes.ContentState {
SampleLiveActivityAttributes.ContentState(status:LVStatus.started)
}

fileprivate static var stateInProgress: SampleLiveActivityAttributes.ContentState {
SampleLiveActivityAttributes.ContentState(status:LVStatus.inProgress)
}

fileprivate static var stateCompleted: SampleLiveActivityAttributes.ContentState {
SampleLiveActivityAttributes.ContentState(status:LVStatus.completed)
}
}

#Preview("Notification", as: .content, using: SampleLiveActivityAttributes.preview) {
SampleLiveActivityLiveActivity()
} contentStates: {
SampleLiveActivityAttributes.ContentState.stateStarted
SampleLiveActivityAttributes.ContentState.stateInProgress
SampleLiveActivityAttributes.ContentState.stateCompleted
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2020 Google LLC
//
// 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.

import SwiftUI
import WidgetKit

struct SampleLiveActivityView: View {

let context: ActivityViewContext< SampleLiveActivityAttributes>

var body: some View {
VStack {
HStack {
Image(systemName: "cup.and.saucer")
ProgressView(value: context.state.status.rawValue, total: 2)
.tint(.black)
.background(Color.brown)
Image(systemName: "cup.and.saucer.fill")
}
.padding(16)

Text("\(context.state.status.description)")
.font(.system(size: 18, weight: .semibold))
.padding(.bottom)
Text("Instance No: " + String(context.attributes.lvInstanceNumber))
.font(.system(size: 18, weight: .semibold))
.padding(.bottom)
Spacer()
}
.background(Color.brown.opacity(0.6))
}
}
Loading
Loading