Azure Notification Hubs SDK for Apple (#85)

This commit is contained in:
Matthew Podwysocki 2020-08-03 15:32:32 -04:00 коммит произвёл GitHub
Родитель 4a52331708
Коммит 95a407e56d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
632 изменённых файлов: 23532 добавлений и 11702 удалений

4
.clang-format Normal file
Просмотреть файл

@ -0,0 +1,4 @@
BasedOnStyle: LLVM
ColumnLimit: 140
UseTab: Never
IndentWidth: 4

40
.github/ISSUE_TEMPLATE/bug_report.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
***Exception or Stack Trace***
Add the exception log and stack trace if available
**To Reproduce**
Steps to reproduce the behavior:
***Code Snippet***
Add the code snippet that causes the issue.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Setup (please complete the following information):**
- OS: [e.g. iOS 13.x]
- IDE : [e.g. Xcode 11.x]
- Version of the Library used
**Additional context**
Add any other context about the problem here.
**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [ ] Bug Description Added
- [ ] Repro Steps Added
- [ ] Setup information Added

25
.github/ISSUE_TEMPLATE/feature_request.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,25 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE REQ]"
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [ ] Description Added
- [ ] Expected solution specified

24
.github/ISSUE_TEMPLATE/question-query-template.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,24 @@
---
name: Question/Query template
about: Use this template to file a question/query for the SDK team
title: "[QUERY]"
labels: ''
assignees: ''
---
**Query/Question**
A clear and concise ask/query.
***Why is this not a Bug or a feature Request?***
A clear explanation of why is this not a bug or a feature request?
**Setup (please complete the following information if applicable):**
- OS: [e.g. iOS 13.x]
- IDE : [e.g. Xcode 11.x]
- Version of the Library used
**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [ ] Query Added
- [ ] Setup information Added

27
.github/PULL_REQUEST_TEMPLATE.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,27 @@
<!--
Thank you for submitting a pull request! Please add some info (if applicable) to give us some context on the PR.
We will review the PR as soon as possible, leave feedback, add a tag, etc. and let you know what's going on.
Thanks!
The Azure Notification Hubs team -->
Things to consider before you submit the PR:
* [ ] Are tests passing locally?
* [ ] Are the files formatted correctly?
* [ ] Did you add unit tests?
* [ ] Did you test your change with either the sample apps that are included in the repository or with a blank app that uses your change?
## Description
A few sentences describing the overall goals of the pull request.
## Related PRs or issues
List related PRs and other issues.
## Misc
Add what's missing, notes on what you tested, additional thoughts or questions.

88
.github/workflows/analyze-test.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,88 @@
name: analyze-test
on:
push:
branches: [ sdk-v3 ]
pull_request:
branches: [ sdk-v3 ]
jobs:
ios-analyze-test:
runs-on: macos-latest
env:
XC_VERSION: ${{ '11.6' }}
XC_WORKSPACE: ${{ 'WindowsAzureMessaging.xcworkspace' }}
XC_SCHEME: ${{ 'WindowsAzureMessaging iOS Framework' }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Select Xcode
run: "sudo xcode-select -switch /Applications/Xcode_$XC_VERSION.app"
- name: iOS Analyze
run: /usr/bin/xcodebuild analyze -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=iOS Simulator,name=iPhone 11'
- name: iOS Test
run: /usr/bin/xcodebuild test -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=iOS Simulator,name=iPhone 11'
tvos-analyze-test:
runs-on: macos-latest
env:
XC_VERSION: ${{ '11.6' }}
XC_WORKSPACE: ${{ 'WindowsAzureMessaging.xcworkspace' }}
XC_SCHEME: ${{ 'WindowsAzureMessaging tvOS Framework' }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Select Xcode
run: "sudo xcode-select -switch /Applications/Xcode_$XC_VERSION.app"
- name: iOS Analyze
run: /usr/bin/xcodebuild analyze -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=tvOS Simulator,name=Apple TV 4K'
- name: iOS Test
run: /usr/bin/xcodebuild test -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=tvOS Simulator,name=Apple TV 4K'
macos-analyze-test:
runs-on: macos-latest
env:
XC_VERSION: ${{ '11.6' }}
XC_WORKSPACE: ${{ 'WindowsAzureMessaging.xcworkspace' }}
XC_SCHEME: ${{ 'WindowsAzureMessaging macOS Framework' }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Select Xcode
run: "sudo xcode-select -switch /Applications/Xcode_$XC_VERSION.app"
- name: macOS Analyze
run: /usr/bin/xcodebuild analyze -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=macOS'
- name: macOS Test
run: /usr/bin/xcodebuild test -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=macOS'
mac-catalyst-analyze-test:
runs-on: macos-latest
env:
XC_VERSION: ${{ '11.6' }}
XC_WORKSPACE: ${{ 'WindowsAzureMessaging.xcworkspace' }}
XC_SCHEME: ${{ 'WindowsAzureMessaging iOS Framework' }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Select Xcode
run: "sudo xcode-select -switch /Applications/Xcode_$XC_VERSION.app"
- name: macOS Analyze
run: /usr/bin/xcodebuild analyze -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=macOS'
- name: macOS Test
run: /usr/bin/xcodebuild test -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" -destination 'platform=macOS'

48
.github/workflows/framework-docs.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,48 @@
name: framework-docs
on:
push:
branches: [ sdk-v3 ]
pull_request:
branches: [ sdk-v3 ]
jobs:
build-sdk:
runs-on: macos-latest
env:
XC_VERSION: ${{ '11.6' }}
XC_WORKSPACE: ${{ 'WindowsAzureMessaging.xcworkspace' }}
XC_SCHEME: ${{ 'All Frameworks' }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Select Xcode
run: "sudo xcode-select -switch /Applications/Xcode_$XC_VERSION.app"
- name: Update Version
run: |
version="$(Scripts/framework-version.sh)+$(git rev-parse --short $GITHUB_SHA)"
echo "Change version to $version"
Scripts/framework-version.sh "$version"
- name: Print Swift Package
run: |
swift --version
swift package describe
- name: Install Jazzy
run: sudo gem install jazzy --no-document
- name: Build
run: /usr/bin/xcodebuild -workspace "$XC_WORKSPACE" -scheme "$XC_SCHEME" build CODE_SIGNING_ALLOWED=NO
- name: Archive
run: Scripts/build-archive.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: WindowsAzureMessaging
path: WindowsAzureMessaging-SDK-Apple/WindowsAzureMessaging-SDK-Apple*.zip

40
.gitignore поставляемый
Просмотреть файл

@ -5,6 +5,7 @@
## Build generated
build/
DerivedData/
WindowsAzureMessaging-SDK-Apple
## Various settings
*.pbxuser
@ -78,12 +79,37 @@ fastlane/test_output
iOSInjectionProject/
# Project specific
BVT/RunTests.sh
BVT/GHUnitIOS.framework
BVT/WindowsAzureMessaging.framework
BVT/IosSdkTests/Default.png
BVT/IosSdkTests/Default-568h@2x.png
BVT/IosSdkTests/Default@2x.png
src/WindowsAzureMessaging/BVT/RunTests.sh
src/WindowsAzureMessaging/BVT/GHUnitIOS.framework
src/WindowsAzureMessaging/BVT/WindowsAzureMessaging.framework
src/WindowsAzureMessaging/BVT/IosSdkTests/Default.png
src/WindowsAzureMessaging/BVT/IosSdkTests/Default-568h@2x.png
src/WindowsAzureMessaging/BVT/IosSdkTests/Default@2x.png
# Mac OS - specific directory
# macOS specific below
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

9
.gitmodules поставляемый Normal file
Просмотреть файл

@ -0,0 +1,9 @@
[submodule "Vendor/OHHTTPStubs"]
path = Vendor/OHHTTPStubs
url = https://github.com/AliSoftware/OHHTTPStubs.git
[submodule "Vendor/OCMock"]
path = Vendor/OCMock
url = https://github.com/erikdoe/ocmock.git
[submodule "Vendor/OCHamcrest"]
path = Vendor/OCHamcrest
url = https://github.com/hamcrest/OCHamcrest.git

Просмотреть файл

@ -0,0 +1,30 @@
Pod::Spec.new do |s|
s.name = "AzureNotificationHubs-iOS"
s.version = "3.0.0"
s.summary = "Push notifications for consumer and enterprise apps – from any backend to any device platform"
s.description = <<-DESC
Azure Notification Hubs provide an easy-to-use, multiplatform, scaled-out push infrastructure that enables you to send mobile push notifications from any backend (in the cloud or on-premises) to any mobile platform.
DESC
s.author = { "Microsoft" => "http://microsoft.com" }
s.license = { :type => "Apache 2.0", :file => "WindowsAzureMessaging-SDK-Apple/LICENSE" }
s.documentation_url = "https://docs.microsoft.com/en-us/azure/notification-hubs/"
s.homepage = "http://azure.microsoft.com/en-us/services/notification-hubs/"
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.9"
s.tvos.deployment_target = "11.0"
s.source = { :http => "https://github.com/Azure/azure-notificationhubs-ios/releases/download/#{s.version}/WindowsAzureMessaging-SDK-Apple-#{s.version}.zip" }
s.preserve_path = "WindowsAzureMessaging-SDK-Apple/README.md"
s.frameworks = "Foundation", "SystemConfiguration"
s.ios.frameworks = "UIKit"
s.ios.weak_frameworks = "UserNotifications"
s.osx.frameworks = "AppKit"
s.osx.weak_frameworks = "UserNotifications"
s.ios.vendored_frameworks = "WindowsAzureMessaging-SDK-Apple/iOS/WindowsAzureMessaging.framework"
s.osx.vendored_frameworks = "WindowsAzureMessaging-SDK-Apple/macOS/WindowsAzureMessaging.framework"
s.tvos.vendored_frameworks = "WindowsAzureMessaging-SDK-Apple/tvOS/WindowsAzureMessaging.framework"
end

1
CHANGELOG.md Normal file
Просмотреть файл

@ -0,0 +1 @@
# Azure Notification Hubs SDK for Apple

48
Config/App.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,48 @@
#include "./Version.xcconfig"
// :Mark: Deployment
IPHONEOS_DEPLOYMENT_TARGET = 9.0
TVOS_DEPLOYMENT_TARGET = 11.0
MACOSX_DEPLOYMENT_TARGET = 10.15
WATCHOS_DEPLOYMENT_TARGET = 3.2
// :Mark: Build Options
DEBUG_INFORMATION_FORMAT_Debug = dwarf
DEBUG_INFORMATION_FORMAT_Release = dwarf-with-dsym
DEBUG_INFORMATION_FORMAT = $(DEBUG_INFORMATION_FORMAT_$(CONFIGURATION))
// :Mark: Architectures
ONLY_ACTIVE_ARCH_Debug = YES
ONLY_ACTIVE_ARCH_Release = NO
ONLY_ACTIVE_ARCH = $(ONLY_ACTIVE_ARCH_$(CONFIGURATION))
// :Mark: Configuration of warnings.
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES
CLANG_WARN_BOOL_CONVERSION = YES
CLANG_WARN_COMMA = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_INFINITE_RECURSION = YES
CLANG_WARN_INT_CONVERSION = YES
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
CLANG_WARN_SUSPICIOUS_MOVE = YES
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
CLANG_WARN_UNREACHABLE_CODE = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR
GCC_WARN_UNDECLARED_SELECTOR = YES
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_VARIABLE = YES

10
Config/Framework.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,10 @@
DEFINES_MODULE = YES
VERSION_INFO_PREFIX = ""
VERSIONING_SYSTEM = "apple-generic"
CURRENT_PROJECT_VERSION = 1
INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks
MODULEMAP_FILE = $(SRCROOT)/$(PROJECT_NAME)/Support/$(NH_BUILD_PLATFORM).modulemap
INFOPLIST_FILE = $(PROJECT_NAME)/Support/Info.plist
MACH_O_TYPE = staticlib

Просмотреть файл

@ -0,0 +1,21 @@
#include "./Global.xcconfig"
// :Mark: Architectures
ONLY_ACTIVE_ARCH = YES
// :Mark: Build Options
DEBUG_INFORMATION_FORMAT = dwarf
ENABLE_TESTABILITY = YES
VALIDATE_PRODUCT = NO
// :Mark: Apple LLVM 8.1 - Code Generation
GCC_OPTIMIZATION_LEVEL = 0
// :Mark: Apple LLVM 8.1 - Preprocessing
ENABLE_NS_ASSERTIONS = YES
// :Mark: User-Defined
MTL_ENABLE_DEBUG_INFO = YES
// :Mark: GCC_PREPROCESSOR_DEFINITIONS
GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = $(inherited) DEBUG

Просмотреть файл

@ -0,0 +1,26 @@
#include "./Global.xcconfig"
// :Mark: Architectures
ONLY_ACTIVE_ARCH = NO
// :Mark: Build Options
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
ENABLE_TESTABILITY = NO
VALIDATE_PRODUCT = YES
BITCODE_GENERATION_MODE = bitcode
// :Mark: Apple LLVM 8.1 - Code Generation
GCC_OPTIMIZATION_LEVEL = s
// :Mark: Apple LLVM 8.1 - Preprocessing
ENABLE_NS_ASSERTIONS = NO
// :Mark: User-Defined
MTL_ENABLE_DEBUG_INFO = NO
// :Mark: Language - Modules
// Avoid dSYM warnings during build macOS application in release mode.
CLANG_ENABLE_MODULE_DEBUGGING[sdk=macosx*] = NO
// Build without code-coverage to avoid 'undefined symbols' issue.
CLANG_ENABLE_CODE_COVERAGE = NO

164
Config/Global.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,164 @@
#include "./Version.xcconfig"
// :Mark: Architectures
MS_WATCH_ARCHS = armv7k arm64_32
MS_SIM_ARCHS = x86_64 i386
SDKROOT = iphoneos
// :Mark: Deployment
IPHONEOS_DEPLOYMENT_TARGET = 9.0
TVOS_DEPLOYMENT_TARGET = 11.0
MACOSX_DEPLOYMENT_TARGET = 10.9
COPY_PHASE_STRIP = NO
// :Mark: Packaging
PRODUCT_NAME = $(PROJECT_NAME)
// :Mark: Language configurations
CLANG_ENABLE_MODULES = NO
CLANG_ENABLE_OBJC_ARC = YES
CLANG_CXX_LIBRARY = libc++
CLANG_CXX_LANGUAGE_STANDARD = gnu++14
GCC_C_LANGUAGE_STANDARD = gnu99
// :Mark: Search paths
ALWAYS_SEARCH_USER_PATHS = NO
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../WindowsAzureMessaging/WindowsAzureMessaging"/**
// :Mark: Code signing
CODE_SIGN_IDENTITY =
// :Mark: Linking
DEAD_CODE_STRIPPING = NO
// :Mark: Code generation
GCC_NO_COMMON_BLOCKS = YES
// :Mark: Preprocessing
ENABLE_STRICT_OBJC_MSGSEND = YES
// :Mark: OTHER_CFLAGS
GLOBAL_CFLAGS = -Wshorten-64-to-32 -Wall -fstack-protector-strong -fpie
OTHER_CFLAGS = $(GLOBAL_CFLAGS)
// :Mark: Extension API Only
// Make sure we don't use API that are not available in extensions.
// See https://pewpewthespells.com/blog/buildsettings.html for info about the flag.
APPLICATION_EXTENSION_API_ONLY = YES
// :Mark: GCC_PREPROCESSOR_DEFINITIONS
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) NH_C_VERSION="\""$(VERSION_STRING)"\"" NH_C_BUILD="\""$(BUILD_NUMBER)"\""
// :Mark: Configuration of warnings. We're listing every warning that we disabled and explain the reason why.
//
// -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesnt make sense for us.
// -objc-missing-property-synthesis
// This isnt a real issue since we dont have any interest in building on extremely old Clangs.
// (Also, each property that cannot be auto–synthesized triggers at least a warning…)
// -float-equal
// While we could change all 90 instances of floating point comparison to a method that includes an epsilon, this is overkill and not needed.
// See http://stackoverflow.com/questions/11421756/weverything-yielding-comparing-floating-point-with-or-is-unsafe
// -pedantic
// Generates too much noise.
// -padded
// This isnt really an issue to us, since were not programming embedded systems.
// -c++98
// We don't want to compile our code for C++98, no need to be warned about incompatibility.
// -c++98-compat-pedantic
// We don't want to compile our code for C++98, no need to be warned about incompatibility.
// -auto-import
// Standard ``import`` is used by tons of files and C++ code limits the possibility to use @import, so we don't. => Disabled.
// -assign-enum
// A lot of api use enums as params but Apple's docs suggest passing in 0 which causes annoying warnings.
// -exit-time-destructors
// Global destructors are obvious, no need to warn about them.
// -global-constructors
// Global constructors are obvious, no need to warn about them.
// -cast-align
// We're not interested in this one as the Mach-O format is itself well-aligned and the original memory allocation
// happens through malloc() and mmap() which always return at least 16byte alignment.
// Read more about alignment in the c++ reference: http://en.cppreference.com/w/cpp/language/object#Alignment.
WARNING_CFLAGS = -Weverything -Wno-objc-missing-property-synthesis -Wno-float-equal -Wno-pedantic -Wno-padded -Wno-sign-conversion -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-auto-import -Wno-assign-enum -Wno-exit-time-destructors -Wno-global-constructors -Wno-cast-align -Wno-direct-ivar-access
// Unqualified ID
WARNING_CFLAGS_XCODE_1000 = -Wno-objc-messaging-id
WARNING_CFLAGS_XCODE_1100 = $(WARNING_CFLAGS_XCODE_1000)
// These are all partially (but not completely?) independent of WARNING_CFLAGS
// and need to be specified explicitly.
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_MISSING_PARENTHESES = YES
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_UNUSED_VARIABLE = YES
GCC_WARN_UNUSED_VALUE = YES
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_SHADOW = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES
CLANG_WARN_BOOL_CONVERSION = YES
CLANG_WARN_COMMA = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
CLANG_WARN_CXX0X_EXTENSIONS = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR
CLANG_WARN_EMPTY_BODY = YES
CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES
CLANG_WARN_INFINITE_RECURSION = YES
CLANG_WARN_INT_CONVERSION = YES
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
CLANG_WARN_SUSPICIOUS_MOVE = YES
CLANG_WARN_UNREACHABLE_CODE = YES
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES
CLANG_WARN_OBJC_INTERFACE_IVARS = YES
// Enable extra analyze modes
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
CLANG_ANALYZER_NONNULL = YES
CLANG_ANALYZER_GCD_PERFORMANCE = YES
// Enable warnings-are-errors for all modes. Don't do this just yet.
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO
GCC_TREAT_WARNINGS_AS_ERRORS = NO
// Swift Compiler - Code Generation
SWIFT_ENFORCE_EXCLUSIVE_ACCESS = on
// Option for xcframework
BUILD_LIBRARIES_FOR_DISTRIBUTION = YES

Просмотреть файл

@ -0,0 +1,9 @@
#include "./Tests.xcconfig"
#include "./iOS.xcconfig"
OTHER_LDFLAGS = $(OTHER_LDFLAGS) -framework UIKit
LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks
// OCMock and OCHamcrest have a bunch of warnings so we just disable this only for testing.
GCC_TREAT_WARNINGS_AS_ERRORS = NO

Просмотреть файл

@ -0,0 +1,9 @@
#include "./Tests.xcconfig"
#include "./macOS.xcconfig"
OTHER_LDFLAGS = $(OTHER_LDFLAGS) -framework AppKit
LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks $(TOOLCHAIN_DIR)/usr/lib/swift/macosx
// OCMock and OCHamcrest have a bunch of warnings so we just disable this only for testing.
GCC_TREAT_WARNINGS_AS_ERRORS = NO

Просмотреть файл

@ -0,0 +1,13 @@
#include "./Tests.xcconfig"
#include "./tvOS.xcconfig"
OTHER_LDFLAGS = $(OTHER_LDFLAGS) -framework UIKit
LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks
// OCMock and OCHamcrest have a bunch of warnings so we just disable this only for testing.
GCC_TREAT_WARNINGS_AS_ERRORS = NO
// OCHTTPStubs for tvOS cannot generate code coverage data without these flags.
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
DEFINES_MODULE = YES

18
Config/Tests.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,18 @@
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../Vendor/$(NH_BUILD_PLATFORM)"/**
HEADER_SEARCH_PATHS = "$(SRCROOT)/../Vendor/$(NH_BUILD_PLATFORM)"/**
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../Vendor/$(NH_BUILD_PLATFORM)"/**
APPLICATION_EXTENSION_API_ONLY = NO
INFOPLIST_FILE = $(PROJECT_NAME)Tests/Info.plist
// OCMock assumes the use of 'unqualified id'
WARNING_CFLAGS = -Wno-objc-messaging-id
OTHER_CFLAGS = $(inherited) -iframework "$(PLATFORM_DIR)/Developer/Library/Frameworks"
OTHER_LDFLAGS = $(inherited) -ObjC -lz
OTHER_LDFLAGS = $(OTHER_LDFLAGS) -framework Foundation
OTHER_LDFLAGS = $(OTHER_LDFLAGS) -framework Security
OTHER_LDFLAGS = $(OTHER_LDFLAGS) -framework SystemConfiguration
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES

2
Config/Version.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,2 @@
BUILD_NUMBER = 1
VERSION_STRING = 3.0.0

11
Config/iOS.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,11 @@
SDKROOT = iphoneos
TARGETED_DEVICE_FAMILY = 1,2
SUPPORTS_MACCATALYST = YES
ARCHS[sdk=iphoneos*] = $(ARCHS_STANDARD)
SKIP_INSTALL = YES
OTHER_CFLAGS = $(inherited) -fembed-bitcode-marker
OTHER_CFLAGS[config=Release][sdk=iphoneos*] = $(GLOBAL_CFLAGS) -fembed-bitcode
OTHER_CFLAGS[sdk=macosx*] = $(GLOBAL_CFLAGS)
NH_BUILD_PLATFORM = iOS

20
Config/macOS.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,20 @@
SDKROOT = macosx
ARCHS = x86_64
VALID_ARCHS = $(ARCHS) i386
SKIP_INSTALL = YES
NH_BUILD_PLATFORM = macOS
MTL_ENABLE_DEBUG_INFO_Debug = INCLUDE_SOURCE
MTL_ENABLE_DEBUG_INFO_Release = NO
MTL_ENABLE_DEBUG_INFO = $(MTL_ENABLE_DEBUG_INFO_$(CONFIGURATION))
MTL_FAST_MATH = YES
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks
CODE_SIGN_STYLE = Automatic
COMBINE_HIDPI_IMAGES = YES
ENABLE_HARDENED_RUNTIME = YES
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon

12
Config/tvOS.xcconfig Normal file
Просмотреть файл

@ -0,0 +1,12 @@
SDKROOT = appletvos
ARCHS = arm64
ARCHS[sdk=appletvsimulator*] = $(MS_SIM_ARCHS)
VALID_ARCHS = $(ARCHS)
VALID_ARCHS[sdk=appletvsimulator*] = $(MS_SIM_ARCHS)
SKIP_INSTALL = YES
TARGETED_DEVICE_FAMILY = 3
OTHER_CFLAGS = $(inherited) -fembed-bitcode-marker
OTHER_CFLAGS[config=Release][sdk=appletvos*] = $(GLOBAL_CFLAGS) -fembed-bitcode
NH_BUILD_PLATFORM = tvOS

286
NOTICE.txt Normal file
Просмотреть файл

@ -0,0 +1,286 @@
NOTICES AND INFORMATION
Do Not Translate or Localize
This repository for Microsoft Azure Notification Hubs SDK for iOS includes material from the projects listed below.
1. Visual Studio App Center SDK for iOS and macOS (https://github.com/microsoft/appcenter-sdk-apple)
2. OCHamcrest (https://github.com/hamcrest/OCHamcrest)
3. OCMock (https://github.com/erikdoe/ocmock)
4. Reachability (https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007324-Intro-DontLinkElementID_2)
%% Visual Studio App Center SDK for Apple platforms NOTICES AND INFORMATION BEGIN HERE
=========================================
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
=========================================
END OF Visual Studio App Center SDK for Apple platforms NOTICES AND INFORMATION
%% OCHamcrest NOTICES AND INFORMATION BEGIN HERE
=========================================
OCHamcrest by Jon Reid, https://qualitycoding.org/
Copyright 2020 hamcrest.org
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Hamcrest nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(BSD License)
=========================================
END OF OCHamcrest NOTICES AND INFORMATION
%% OCMock NOTICES AND INFORMATION BEGIN HERE
=========================================
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
=========================================
END OF OCMock NOTICES AND INFORMATION
%% Reachability NOTICES AND INFORMATION BEGIN HERE
=========================================
Sample code project: Reachability
Version: 5.0
Copyright (C) 2016 Apple Inc. All Rights Reserved.
IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis.
APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
=========================================
END OF Reachability NOTICES AND INFORMATION

40
Package.swift Normal file
Просмотреть файл

@ -0,0 +1,40 @@
// swift-tools-version:5.0
// Copyright (c) Microsoft Corporation. All rights reserved.
import PackageDescription
let package = Package(
name: "WindowsAzureMessaging",
platforms: [
.iOS(.v9),
.macOS(.v10_10),
.tvOS(.v11)
],
products: [
.library(
name: "WindowsAzureMessaging",
type: .static,
targets: ["WindowsAzureMessaging"]),
],
dependencies: [],
targets: [
.target(
name: "WindowsAzureMessaging",
path: "WindowsAzureMessaging/WindowsAzureMessaging",
exclude: ["Support"],
cSettings: [
.define("NH_C_VERSION", to:"\"3.0.0\""),
.define("NH_C_BUILD", to:"\"1\""),
.headerSearchPath("**"),
],
linkerSettings: [
.linkedFramework("Foundation"),
.linkedFramework("SystemConfiguration"),
.linkedFramework("UserNotifications"),
.linkedFramework("AppKit", .when(platforms: [.macOS])),
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS]))
]
)
]
)

465
README.md
Просмотреть файл

@ -1,33 +1,468 @@
# Microsoft Azure Notification Hubs SDK for iOS
# Microsoft Azure Notification Hubs SDK for Apple
Microsoft Azure Notification Hubs provide a multiplatform, scaled-out push infrastructure that enables you to send mobile push notifications from any backend (in the cloud or on-premises) to any mobile platform. To learn more, visit our [Developer Center](https://azure.microsoft.com/en-us/documentation/services/notification-hubs).
The Azure Notification Hubs SDK for Apple provides capabilities for registering your device and receive push notifications on macOS and iOS including platforms including tvOS, watchOS and Mac Catalyst.
## Getting Started
If you are new to Notification Hubs, you can get started by following our tutorials to push notifications to your [iOS apps](https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-ios-get-started/).
The Azure Notification Hubs can be added to your app via Cocoapods, Carthage, Swift Package Manager, or by manually adding the binaries to your project. We have a number of sample applications available written in both Swift and Objective-C to help you get started for both iOS with Mac Catalyst support, and a macOS sample, and SwiftUI coming soon.
## Download Source Code
**This introduces a new API as of version 3.0, and the usage of `SBNotificationHub` with registrations is still supported, but discouraged as we have the new `MSNotificationHub` which uses the Installation API and modern Apple APIs.**
To get the source code of our SDKs via **git** just type:
1. NH Sample App for iOS/Mac Catalyst ([Swift](SampleNHAppSwift) | [Objective-C](SampleNHAppObjC))
2. NH Sample App for macOS ([Swift](SampleNHAppMacSwift) | [Objective-C](SampleNHAppMacObjC))
3. NH Sample App for SwiftUI ([iOS](SampleNHAppSwiftUI) | [macOS](SampleNHAppMacSwiftUI))
4. NH Sample Legacy App using Legacy APIs ([Swift](SampleNHAppLegacySwift) | [Objective-C](SampleNHAppLegacyObjC))
git clone https://github.com/Azure/azure-notificationhubs-ios.git
### Integration with Cocoapods
Add the following into your `podfile` to pull in the Azure Notification Hubs SDK:
```ruby
pod 'AzureNotificationHubs-iOS'
```
Run `pod install` to install the pod and then open your project workspace in Xcode.
### Integration with Carthage
Below are the steps on how to integrate the Azure Notification Huds SDK in your Xcode project using Carthage version 0.30 or higher. Add the following to your `Cartfile` to include GitHub repository.
```ruby
# Gets the latest release
github "Azure/azure-notificationhubs-ios"
```
You can also specify a specific version of the Azure Notification Hubs SDK such as 3.0.0.
```ruby
# Get version in the format of X.X.X such as 3.0.0
github "Azure/azure-notificationhubs-ios" ~> 3.0.0
```
Once you have this, run `carthage update`. This will fetch the SDK and put it into the `Carthage/Checkouts` folder. Open Xcode and drag the `WindowsAzureMessaging.framework` from the `Carthage/Builds/iOS` for iOS or `Carthage/Builds/macOS` for macOS. Ensure the app target is checked during the import.
### Integration via Swift Package Manager
The Azure Notification Hubs SDK also supports the Swift Package Manager. To integrate, use the following steps:
1. From the Xcode menu click File > Swift Packages > Add Package Dependency.
2. In the dialog, enter the repository URL: `http://github.com/Azure/azure-notificationhubs-ios.git`
3. In the Version, select Up to Next Major and take the default option.
4. Choose WindowsAzureMessaging in the Package Product column.
### Integration via copying binaries
The Azure Notification Hubs SDK can also be added manually by downloading the release from GitHub on the [Azure Notification Hubs SDK Releases](https://github.com/Azure/azure-notificationhubs-ios/releases).
The SDK supports the use of XCframework. If you want to integrate XCframeworks into your project, download the WindowsAzureMessaging-SDK-Apple-XCFramework.zip from the releases page and unzip it. Resulting folder contents are not platform-specific, instead it contains the XCframework.
Unzip the file and you will see a folder called WindowsAzureMessaging-SDK-Apple that contains the framework files each platform folder. Copy the framework to a desired location and then add to Xcode. Ensure the app target is checked during the import.
### Initializing the SDK
To get started with the SDK, you need to configure your Azure Notification Hub with your Apple credentials. To integrate the SDK, you will need the name of the hub as well as a connection string from your Access Policies. Note that you only need the "Listen" permission to intercept push notifications.
You can then import the headers for Swift:
```swift
import WindowsAzureMessaging
```
And Objective-C as well:
```objc
#import <WindowsAzureMessaging/WindowsAzureMessaging.h>
```
Then we can initialize the SDK with our hub name and connection string. This will automatically register the device using the [Installation API](https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#installations) with your device token.
Using Swift, we can use the `start` method, which then starts the installation and device registration process for push notifications.
Swift:
```swift
let connectionString = "<connection-string>"
let hubName = "<hub-name>"
MSNotificationHub.start(connectionString: connectionString!, hubName: hubName!)
```
With Objective-C, it is largely the same with calling the `startWithConnectionString` method:
Objective-C:
```objc
NSString *connectionString = @"<connection-string>";
NSString *hubName = @"<hub-name>";
[MSNotificationHub startWithConnectionString:connectionString hubName:hubName];
```
### Intercepting Push Notifications
You can set up a delegate to be notified whenever a push notification is received in foreground or a background push notification has been tapped by the user. To get started with intercepting push notifications, implement the `MSNotificationHubDelegate`, and use the `MSNotificationHub.setDelegate` method to set the delegate implementation.
Swift:
```swift
class SetupViewController: MSNotificationHubDelegate // And other imports
// Set up the delegate
MSNotificationHub.setDelegate(self)
// Implement the method
func notificationHub(_ notificationHub: MSNotificationHub!, didReceivePushNotification notification: MSNotificationHubMessage!) {
let title = notification.title ?? ""
let body = notification.body ?? ""
if (UIApplication.shared.applicationState == .background) {
NSLog("Notification received in background: title:\"\(title)\" body:\"\(body)\"")
} else {
let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .cancel))
self.present(alertController, animated: true)
}
}
```
Objective-C:
```objc
@interface SetupViewController <MSNotificationHubDelegate /* Other protocols */>
// Set up the delegate
[MSNotificationHub setDelegate:self];
// Implement the method
- (void)notificationHub:(MSNotificationHub *)notificationHub didReceivePushNotification:(MSNotificationHubMessage *)notification {
NSString *title = notification.title ?: @"";
NSString *body = notification.body ?: @"";
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
NSLog(@"Notification received in the background: title: %@ body: %@", title, body);
} else {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:notification.title
message:notification.body
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
}
}
```
### Tag Management
One of the ways to target a device or set of devices is through the use of [tags](https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message#tags), where you can target a specific tag, or a tag expression. The Azure Notification Hub SDK for Apple handles this through top level methods that allow you to add, clear, remove and get all tags for the current installation. In this example, we can add some recommended tags such as the app language preference, and device country code.
Swift:
```swift
// Get language and country code for common tag values
let language = Bundle.main.preferredLocalizations.first!
let countryCode = NSLocale.current.regionCode!
// Create tags with type_value format
let languageTag = "language_" + language
let countryCodeTag = "country_" + countryCode
MSNotificationHub.addTags([languageTag, countryCodeTag])
```
Objective-C:
```objc
// Get language and country code for common tag values
NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
NSString *countryCode = [[NSLocale currentLocale] countryCode];
// Create tags with type_value format
NSString *languageTag = [NSString stringWithFormat:@"language_%@", language];
NSString *countryCodeTag = [NSString stringWithFormat:@"country_%@", countryCode];
[MSNotificationHub addTags:@[languageTag, countryCodeTag]];
```
### Template Management
With [Azure Notification Hub Templates](https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-templates-cross-platform-push-messages), you can enable a client application to specify the exact format of the notifications it wants to receive. This is useful when you want to create a more personalized notification, with string replacement to fill the values. The Installation API [allows multiple templates](https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#templates) for each installation which gives you greater power to target your users with rich messages.
For example, we can create a template with a body, some headers, and some tags.
Swift:
```swift
// Get language and country code for common tag values
let language = Bundle.main.preferredLocalizations.first!
let countryCode = NSLocale.current.regionCode!
// Create tags with type_value format
let languageTag = "language_" + language
let countryCodeTag = "country_" + countryCode
let body = "{\"aps\": {\"alert\": \"$(message)\"}}"
let template = MSInstallationTemplate()
template.body = body
template.addTags([languageTag, countryCodeTag])
MSNotificationHub.setTemplate(template, forKey: "template1")
```
Objective-C:
```objc
NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
NSString *countryCode = [[NSLocale currentLocale] countryCode];
// Create tags with type_value format
NSString *languageTag = [NSString stringWithFormat:@"language_%@", language];
NSString *countryCodeTag = [NSString stringWithFormat:@"country_%@", countryCode];
NSString *body = @"{\"aps\": {\"alert\": \"$(message)\"}}";
MSInstallationTemplate *template = [MSInstallationTemplate new];
template.body = body;
[template addTags:@[languageTag, countryCodeTag]];
[MSNotificationHub setTemplate:template forKey:@"template1"];
```
### Intercepting Installation Management
The SDK will handle saving the installation for you, however, we provide hooks where you can intercept both the successful installation or any failure through the `MSInstallationLifecycleDelegate`. This has two methods, `didSaveInstallation` for successful saves, and `didFailToSaveInstallation` for any failures. We can implement this to have our own logging for example.
Swift:
```swift
// Set the delegate
MSNotificationHub.setLifecycleDelegate(self)
// Handle success
func notificationHub(_ notificationHub: MSNotificationHub!, didSave installation: MSInstallation!) {
let installationId = installation.installationId;
NSLog("Successful save with Installation ID: \"\(installationId)\"")
}
// Handle failure
func notificationHub(_ notificationHub: MSNotificationHub!, didFailToSave installation: MSInstallation!, withError error: Error!) {
NSLog("Failed to save installation")
}
```
Objective-C:
```objc
// Set the delegate
[MSNotificationHub setLifecycleDelegate:self];
// Handle successes
- (void)notificationHub:(MSNotificationHub *)notificationHub didSaveInstallation:(MSInstallation *)installation {
NSLog(@"Successful save with Installation ID: %@", installation.installationId);
}
// Handle failure
- (void)notificationHub:(MSNotificationHub *)notificationHub
didFailToSaveInstallation:(MSInstallation *)installation
withError:(NSError *)error {
NSLog(@"Failed to save installation with error %@", [error localizedDescription]);
}
```
### Enriching Installations
The SDK will update the installation on the device any time you change its properties such as adding a tag or adding an installation template. Before the installation is sent to the backend, you can intercept this installation to modify anything before it goes to the backend, for example, if you wish to add or modify tags. This is implemented in the `MSInstallationEnrichmentDelegate` protocol with a single method of `willEnrichInstallation`.
Swift:
```swift
// Set the delegate
MSNotificationHub.setEnrichmentDelegate(self)
// Handle the enrichment
func notificationHub(_ notificationHub: MSNotificationHub!, willEnrichInstallation installation: MSInstallation!) {
installation.addTag("customTag")
}
```
Objective-C:
```objc
// Set the delegate
[MSNotificationHub setEnrichmentDelegate:self];
// Handle the enrichment
- (void)notificationHub:(MSNotificationHub *)notificationHub willEnrichInstallation:(MSInstallation *)installation {
// Add another tag
[installation addTag:@"customTag"];
}
```
### Saving Installations to a Custom Backend
The Azure Notification Hubs SDK will save the installation to our backend by default. If, however, you wish to skip our backend and store it on your backend, we support that through the `MSInstallationManagementDelegate` protocol. This has a method to save the installation `willUpsertInstallation`, passing in the installation, and then a completion handler is called with either an error if unsuccessful, or nil if successful. To set the delegate, instead of specifying the connection string and hub name, you specify the installation manager with `startWithInstallationManagement`
Swift:
```swift
// Set the delegate
MSNotificationHub.startWithInstallationManagement(self)
func notificationHub(_ notificationHub: MSNotificationHub!, willUpsertInstallation installation: MSInstallation!, withCompletionHandler completionHandler: @escaping (NSError?) -> Void) {
// Save to your own backend
// Call the completion handler with no error if successful
completionHandler(nil);
}
```
Objective-C:
```objc
// Set the delegate
[MSNotificationHub startWithInstallationManagement:self];
// Save to your own backend
- (void)notificationHub:(MSNotificationHub *)notificationHub
willUpsertInstallation:(MSInstallation *)installation
completionHandler:(void (^)(NSError *_Nullable))completionHandler {
// Save to your own backend
// Call the completion handler with no error if successful
completionHandler(nil);
}
```
### Disabling Automatic Swizzling
By default, the SDK will swizzle methods to automatically intercept calls to `UIApplicationDelegate`/`NSApplicationDelegate` for calls to registering and intercepting push notifications, as well as `UNUserNotificationCenterDelegate` methods. Note this is only available for iOS, watchOS, and Mac Catalyst. This is not supported on macOS and tvOS.
#### Disabling UIApplicationDelegate/NSApplicationDelegate
1. Open the project's Info.plist
2. Add the `NHAppDelegateForwarderEnabled` key and set the value to 0. This disables the UIApplicationDelegate/NSApplicationDelegate auto-forwarding to MSNotificaitonHub.
3. Implement the `MSApplicationDelegate`/`NSApplicationDelegate` methods for push notifications.
Implement the application:didRegisterForRemoteNotificationsWithDeviceToken: callback and the application:didFailToRegisterForRemoteNotificationsWithError: callback in your AppDelegate to register for Push notifications. In the code below, if on macOS, not Mac Catalyst, replace `UIApplication` with `NSApplication`.
Swift:
```swift
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// Pass the device token to MSNotificationHub
MSNotificationHub.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
// Pass the error to MSNotificationHub
MSNotificationHub.didFailToRegisterForRemoteNotificationsWithError(error)
}
```
Objective-C:
```objc
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Pass the device token to MSNotificationHub
[MSNotificationHub didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
// Pass the error to MSNotificationHub
[MSNotificationHub didFailToRegisterForRemoteNotificationsWithError:error];
}
```
4. Implement the callback to receive push notifications
Implement the application:didReceiveRemoteNotification:fetchCompletionHandler callback to forward push notifications to MSNotificationHub In the code below, if on macOS, not Mac Catalyst, replace `UIApplication` with `NSApplication`.
Swift:
```swift
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// Forward to MSNotificationHub
MSNotificationHub.didReceiveRemoteNotification(userInfo)
// Complete handling the notification
completionHandler(.noData)
}
```
Objective-C:
```objc
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Forward to MSNotificationHub
[MSNotificationHub didReceiveRemoteNotification:userInfo];
// Complete handling the notification
completionHandler(UIBackgroundFetchResultNoData);
}
```
#### Disabling UNUserNotificationCenterDelegate
1. Open the project's Info.plist
2. Add the `NHUserNotificationCenterDelegateForwarderEnabled` key and set the value to 0. This disables the UNUserNotificationCenterDelegate auto-forwarding to MSNotificaitonHub.
3. Implement UNUserNotificationCenterDelegate callbacks and pass the notification's payload to `MSNotificationHub`.
Swift:
```swift
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
//...
// Pass the notification payload to MSNotificationHub
MSNotificationHub.didReceiveRemoteNotification(notification.request.content.userInfo)
// Complete handling the notification
completionHandler([])
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
//...
// Pass the notification payload to MSNotificationHub
MSNotificationHub.didReceiveRemoteNotification(response.notification.request.content.userInfo)
// Complete handling the notification
completionHandler()
}
```
Objective-C:
```objc
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
API_AVAILABLE(ios(10.0), tvos(10.0), watchos(3.0)) {
//...
// Pass the notification payload to MSNotificationHub
[MSNotificationHub didReceiveRemoteNotification:notification.request.content.userInfo];
// Complete handling the notification
completionHandler(UNNotificationPresentationOptionNone);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0), tvos(10.0), watchos(3.0)) {
//...
[MSNotificationHub didReceiveRemoteNotification:response.notification.request.content.userInfo];
// Complete handling the notification
completionHandler();
}
```
## Useful Resources
* [Samples](https://github.com/azure/azure-notificationhubs-ios/tree/master/Samples/) in [Objective-C](https://github.com/azure/azure-notificationhubs-ios/tree/master/Samples/Objective-C/) and [Swift](https://github.com/Azure/azure-notificationhubs-ios/tree/master/Samples/Swift)
* Tutorials and product overview are available at [Microsoft Azure Notification Hubs Developer Center](https://azure.microsoft.com/en-us/documentation/services/notification-hubs).
* Our product team actively monitors the [Notification Hubs Developer Forum](http://social.msdn.microsoft.com/Forums/en-US/notificationhubs/) to assist you with any troubles.
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
All Objective-C files follow LLVM coding style (with a few exceptions) and are formatted accordingly. To format your changes, make sure you have the clang-format tool. It can be installed with Homebrew using the command `brew install clang-format`. Once you have installed clang-format, run `./clang-format-changed-files.sh` from the repository root - this will format all files that have changes against the remote `master` branch (it will also perform a git fetch).
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

Просмотреть файл

@ -0,0 +1,279 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
4C1C0E4E24D7E0A60019A46B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0E4D24D7E0A60019A46B /* AppDelegate.m */; };
4C1C0E5424D7E0A60019A46B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0E5324D7E0A60019A46B /* ViewController.m */; };
4C1C0E5924D7E0A80019A46B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0E5824D7E0A80019A46B /* Assets.xcassets */; };
4C1C0E5F24D7E0A80019A46B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0E5E24D7E0A80019A46B /* main.m */; };
4C1C0E6724D7E31D0019A46B /* DevSettings.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0E6624D7E31D0019A46B /* DevSettings.plist */; };
4C1C0E7124D7E66F0019A46B /* NotificationDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0E7024D7E66F0019A46B /* NotificationDetailViewController.m */; };
4C1C0E7324D7E6890019A46B /* NotificationDetail.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0E7224D7E6890019A46B /* NotificationDetail.xib */; };
4C1C0E7624D7E89C0019A46B /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0E7524D7E89C0019A46B /* Constants.m */; };
4C1C0E7924D7E9720019A46B /* WindowsAzureMessaging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1C0E7824D7E9720019A46B /* WindowsAzureMessaging.framework */; };
4C1C0E7E24D85B470019A46B /* Splash.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0E7D24D85B470019A46B /* Splash.png */; };
4C1C0E8324D85DFB0019A46B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0E7F24D85DFB0019A46B /* LaunchScreen.storyboard */; };
4C1C0E8424D85DFB0019A46B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0E8124D85DFB0019A46B /* Main.storyboard */; };
4C1C0E8724D860A80019A46B /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0E8624D860A80019A46B /* SceneDelegate.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
4C1C0E4924D7E0A60019A46B /* SampleNHAppLegacyObjC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleNHAppLegacyObjC.app; sourceTree = BUILT_PRODUCTS_DIR; };
4C1C0E4C24D7E0A60019A46B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4C1C0E4D24D7E0A60019A46B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
4C1C0E5224D7E0A60019A46B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
4C1C0E5324D7E0A60019A46B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
4C1C0E5824D7E0A80019A46B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4C1C0E5D24D7E0A80019A46B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4C1C0E5E24D7E0A80019A46B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4C1C0E6524D7E1680019A46B /* SampleNHAppLegacyObjC.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SampleNHAppLegacyObjC.entitlements; sourceTree = "<group>"; };
4C1C0E6624D7E31D0019A46B /* DevSettings.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = DevSettings.plist; sourceTree = "<group>"; };
4C1C0E6F24D7E66F0019A46B /* NotificationDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationDetailViewController.h; sourceTree = "<group>"; };
4C1C0E7024D7E66F0019A46B /* NotificationDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationDetailViewController.m; sourceTree = "<group>"; };
4C1C0E7224D7E6890019A46B /* NotificationDetail.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NotificationDetail.xib; sourceTree = "<group>"; };
4C1C0E7424D7E8760019A46B /* Constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
4C1C0E7524D7E89C0019A46B /* Constants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = "<group>"; };
4C1C0E7824D7E9720019A46B /* WindowsAzureMessaging.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WindowsAzureMessaging.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4C1C0E7D24D85B470019A46B /* Splash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Splash.png; sourceTree = "<group>"; };
4C1C0E8024D85DFB0019A46B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4C1C0E8224D85DFB0019A46B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4C1C0E8524D860880019A46B /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
4C1C0E8624D860A80019A46B /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
4C1C0EE124D888DC0019A46B /* SampleNHApp.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SampleNHApp.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4C1C0E4624D7E0A60019A46B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4C1C0E7924D7E9720019A46B /* WindowsAzureMessaging.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4C1C0E4024D7E0A60019A46B = {
isa = PBXGroup;
children = (
4C1C0E4B24D7E0A60019A46B /* SampleNHAppLegacyObjC */,
4C1C0E4A24D7E0A60019A46B /* Products */,
4C1C0E7724D7E9720019A46B /* Frameworks */,
);
sourceTree = "<group>";
};
4C1C0E4A24D7E0A60019A46B /* Products */ = {
isa = PBXGroup;
children = (
4C1C0E4924D7E0A60019A46B /* SampleNHAppLegacyObjC.app */,
);
name = Products;
sourceTree = "<group>";
};
4C1C0E4B24D7E0A60019A46B /* SampleNHAppLegacyObjC */ = {
isa = PBXGroup;
children = (
4C1C0EDF24D888980019A46B /* Support */,
4C1C0E7F24D85DFB0019A46B /* LaunchScreen.storyboard */,
4C1C0E8124D85DFB0019A46B /* Main.storyboard */,
4C1C0E7D24D85B470019A46B /* Splash.png */,
4C1C0E5824D7E0A80019A46B /* Assets.xcassets */,
4C1C0E4C24D7E0A60019A46B /* AppDelegate.h */,
4C1C0E4D24D7E0A60019A46B /* AppDelegate.m */,
4C1C0E7424D7E8760019A46B /* Constants.h */,
4C1C0E7524D7E89C0019A46B /* Constants.m */,
4C1C0E6624D7E31D0019A46B /* DevSettings.plist */,
4C1C0E5D24D7E0A80019A46B /* Info.plist */,
4C1C0E5E24D7E0A80019A46B /* main.m */,
4C1C0E7224D7E6890019A46B /* NotificationDetail.xib */,
4C1C0E6F24D7E66F0019A46B /* NotificationDetailViewController.h */,
4C1C0E7024D7E66F0019A46B /* NotificationDetailViewController.m */,
4C1C0E6524D7E1680019A46B /* SampleNHAppLegacyObjC.entitlements */,
4C1C0E5224D7E0A60019A46B /* ViewController.h */,
4C1C0E5324D7E0A60019A46B /* ViewController.m */,
4C1C0E8524D860880019A46B /* SceneDelegate.h */,
4C1C0E8624D860A80019A46B /* SceneDelegate.m */,
);
path = SampleNHAppLegacyObjC;
sourceTree = "<group>";
};
4C1C0E7724D7E9720019A46B /* Frameworks */ = {
isa = PBXGroup;
children = (
4C1C0E7824D7E9720019A46B /* WindowsAzureMessaging.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
4C1C0EDF24D888980019A46B /* Support */ = {
isa = PBXGroup;
children = (
4C1C0EE124D888DC0019A46B /* SampleNHApp.xcconfig */,
);
path = Support;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
4C1C0E4824D7E0A60019A46B /* SampleNHAppLegacyObjC */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4C1C0E6224D7E0A80019A46B /* Build configuration list for PBXNativeTarget "SampleNHAppLegacyObjC" */;
buildPhases = (
4C1C0E4524D7E0A60019A46B /* Sources */,
4C1C0E4624D7E0A60019A46B /* Frameworks */,
4C1C0E4724D7E0A60019A46B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = SampleNHAppLegacyObjC;
productName = SampleNHAppLegacyObjC;
productReference = 4C1C0E4924D7E0A60019A46B /* SampleNHAppLegacyObjC.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
4C1C0E4124D7E0A60019A46B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = Microsoft;
TargetAttributes = {
4C1C0E4824D7E0A60019A46B = {
CreatedOnToolsVersion = 11.6;
};
};
};
buildConfigurationList = 4C1C0E4424D7E0A60019A46B /* Build configuration list for PBXProject "SampleNHAppLegacyObjC" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 4C1C0E4024D7E0A60019A46B;
productRefGroup = 4C1C0E4A24D7E0A60019A46B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
4C1C0E4824D7E0A60019A46B /* SampleNHAppLegacyObjC */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
4C1C0E4724D7E0A60019A46B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C1C0E7324D7E6890019A46B /* NotificationDetail.xib in Resources */,
4C1C0E7E24D85B470019A46B /* Splash.png in Resources */,
4C1C0E5924D7E0A80019A46B /* Assets.xcassets in Resources */,
4C1C0E8424D85DFB0019A46B /* Main.storyboard in Resources */,
4C1C0E8324D85DFB0019A46B /* LaunchScreen.storyboard in Resources */,
4C1C0E6724D7E31D0019A46B /* DevSettings.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
4C1C0E4524D7E0A60019A46B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C1C0E7624D7E89C0019A46B /* Constants.m in Sources */,
4C1C0E8724D860A80019A46B /* SceneDelegate.m in Sources */,
4C1C0E7124D7E66F0019A46B /* NotificationDetailViewController.m in Sources */,
4C1C0E5424D7E0A60019A46B /* ViewController.m in Sources */,
4C1C0E4E24D7E0A60019A46B /* AppDelegate.m in Sources */,
4C1C0E5F24D7E0A80019A46B /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
4C1C0E7F24D85DFB0019A46B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
4C1C0E8024D85DFB0019A46B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
4C1C0E8124D85DFB0019A46B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
4C1C0E8224D85DFB0019A46B /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
4C1C0E6024D7E0A80019A46B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4C1C0EE124D888DC0019A46B /* SampleNHApp.xcconfig */;
buildSettings = {
ENABLE_TESTABILITY = YES;
};
name = Debug;
};
4C1C0E6124D7E0A80019A46B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4C1C0EE124D888DC0019A46B /* SampleNHApp.xcconfig */;
buildSettings = {
};
name = Release;
};
4C1C0E6324D7E0A80019A46B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
};
name = Debug;
};
4C1C0E6424D7E0A80019A46B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
4C1C0E4424D7E0A60019A46B /* Build configuration list for PBXProject "SampleNHAppLegacyObjC" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4C1C0E6024D7E0A80019A46B /* Debug */,
4C1C0E6124D7E0A80019A46B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4C1C0E6224D7E0A80019A46B /* Build configuration list for PBXNativeTarget "SampleNHAppLegacyObjC" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4C1C0E6324D7E0A80019A46B /* Debug */,
4C1C0E6424D7E0A80019A46B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 4C1C0E4124D7E0A60019A46B /* Project object */;
}

Просмотреть файл

@ -0,0 +1,16 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
@property (strong, nonatomic) UIWindow *window;
- (void)handleRegister;
- (void)handleUnregister;
@end

Просмотреть файл

@ -1,11 +1,11 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import "AppDelegate.h"
#import "Constants.h"
#import "NotificationDetailViewController.h"
#import <WindowsAzureMessaging/WindowsAzureMessaging.h>
@interface AppDelegate ()
@ -13,48 +13,24 @@
@implementation AppDelegate
////////////////////////////////////////////////////////////////////////////////
//
// UIApplicationDelegate methods
//
////////////////////////////////////////////////////////////////////////////////
//
// Tells the delegate that the launch process is almost done and the app is almost ready to run.
//
// https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622921-application?language=objc
//
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//
// It is important to always set the UNUserNotificationCenterDelegate when the app launches. Otherwise the app
// may miss some notifications.
//
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
return YES;
}
//
// Tells the app that a remote notification arrived that indicates there is data to be fetched.
//
// https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application?language=objc
//
#pragma mark UIApplicationDelegate Methods
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
NSLog(@"Received remote (silent) notification");
[self logNotificationDetails:userInfo];
//
// Let the system know the silent notification has been processed.
//
completionHandler(UIBackgroundFetchResultNoData);
}
//
// Tells the delegate that the app successfully registered with Apple Push Notification service (APNs).
//
// https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622958-application?language=objc
//
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSMutableSet *tags = [[NSMutableSet alloc] init];
@ -80,72 +56,32 @@
}];
}
////////////////////////////////////////////////////////////////////////////////
//
// UNUserNotificationCenterDelegate methods
//
////////////////////////////////////////////////////////////////////////////////
#pragma mark - UNUserNotificationCenterDelegate Methods
//
// Asks the delegate how to handle a notification that arrived while the app was running in the foreground.
//
// https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=objc
//
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
NSLog(@"Received notification while the application is in the foreground");
//
// The system calls this delegate method when the app is in the foreground. This allows the app to handle the notification
// itself (and potentially modify the default system behavior).
//
//
// Handle the notification by displaying custom UI.
//
[self showNotification:notification.request.content.userInfo];
//
// Use 'options' to specify which default behaviors to enable.
// https://developer.apple.com/documentation/usernotifications/unnotificationpresentationoptions?language=objc
// - UNAuthorizationOptionBadge: Apply the notification's badge value to the apps icon.
// - UNAuthorizationOptionSound: Play the sound associated with the notification.
// - UNAuthorizationOptionAlert: Display the alert using the content provided by the notification.
//
// In this case, do not pass UNAuthorizationOptionAlert because the notification was handled by the app.
//
completionHandler(UNAuthorizationOptionBadge | UNAuthorizationOptionSound);
}
//
// Asks the delegate to process the user's response to a delivered notification.
//
// https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=objc
//
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
NSLog(@"Received notification while the application is in the background");
//
// The system calls this delegate method when the user taps or responds to the system notification.
//
//
// Handle the notification response by displaying custom UI
//
[self showNotification:response.notification.request.content.userInfo];
//
// Let the system know the response has been processed.
//
completionHandler();
}
////////////////////////////////////////////////////////////////////////////////
//
// App logic and helpers
//
////////////////////////////////////////////////////////////////////////////////
#pragma mark - AppDelegate Helpers
- (SBNotificationHub *)getNotificationHub {
NSString *hubName = [[NSBundle mainBundle] objectForInfoDictionaryKey:NHInfoHubName];
NSString *connectionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:NHInfoConnectionString];
NSString *path = [[NSBundle mainBundle] pathForResource:@"DevSettings" ofType:@"plist"];
NSDictionary *configValues = [NSDictionary dictionaryWithContentsOfFile:path];
NSString *connectionString = [configValues objectForKey:@"CONNECTION_STRING"];
NSString *hubName = [configValues objectForKey:@"HUB_NAME"];
return [[SBNotificationHub alloc] initWithConnectionString:connectionString notificationHubPath:hubName];
}
@ -163,9 +99,6 @@
}
- (void)handleUnregister {
//
// Unregister the device with the Notification Hub.
//
SBNotificationHub *hub = [self getNotificationHub];
[hub unregisterNativeWithCompletion:^(NSError* error) {
if (error != nil) {
@ -200,4 +133,21 @@
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:notificationDetail animated:YES completion:nil];
}
#pragma mark - UISceneSession lifecycle
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
@end

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 441 B

После

Ширина:  |  Высота:  |  Размер: 441 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 772 B

После

Ширина:  |  Высота:  |  Размер: 772 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.0 KiB

После

Ширина:  |  Высота:  |  Размер: 1.0 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 598 B

После

Ширина:  |  Высота:  |  Размер: 598 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 992 B

После

Ширина:  |  Высота:  |  Размер: 992 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.3 KiB

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 772 B

После

Ширина:  |  Высота:  |  Размер: 772 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.3 KiB

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.7 KiB

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 991 B

После

Ширина:  |  Высота:  |  Размер: 991 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.7 KiB

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.5 KiB

После

Ширина:  |  Высота:  |  Размер: 2.5 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.1 KiB

После

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.2 KiB

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.3 KiB

После

Ширина:  |  Высота:  |  Размер: 2.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 916 B

После

Ширина:  |  Высота:  |  Размер: 916 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.5 KiB

После

Ширина:  |  Высота:  |  Размер: 1.5 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 14 KiB

После

Ширина:  |  Высота:  |  Размер: 14 KiB

Просмотреть файл

@ -0,0 +1,12 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#ifndef Constants_h
#define Constants_h
extern NSString* const NHInfoConnectionString;
extern NSString* const NHInfoHubName;
extern NSString* const NHUserDefaultTags;
#endif /* Constants_h */

Просмотреть файл

@ -1,7 +1,6 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import <Foundation/Foundation.h>
#import "Constants.h"

Просмотреть файл

@ -0,0 +1,10 @@
<?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>HUB_NAME</key>
<string></string>
<key>CONNECTION_STRING</key>
<string></string>
</dict>
</plist>

Просмотреть файл

@ -4,8 +4,6 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>NH Sample</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@ -15,17 +13,13 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NotificationHubConnectionString</key>
<string>CONNECTIONSTRING</string>
<key>NotificationHubName</key>
<string>HUBNAME</string>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
@ -34,6 +28,25 @@
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
@ -41,13 +54,15 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

Просмотреть файл

@ -1,7 +1,6 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import <UIKit/UIKit.h>

Просмотреть файл

@ -1,7 +1,6 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import "NotificationDetailViewController.h"
@ -11,29 +10,6 @@
@implementation NotificationDetailViewController
////////////////////////////////////////////////////////////////////////////////
//
// UIViewController methods
//
////////////////////////////////////////////////////////////////////////////////
- (id)initWithUserInfo:(NSDictionary *)userInfo {
self = [super initWithNibName:@"NotificationDetail" bundle:nil];
if (self) {
_userInfo = userInfo;
}
return self;
}
- (void)viewDidLayoutSubviews {
//
// Workaround the fact that UILabel doesn't support top-left aligned text.
// Instead resize the control to fit the specified text.
//
[self.titleLabel sizeToFit];
[self.bodyLabel sizeToFit];
}
- (void)viewDidLoad {
[super viewDidLoad];
@ -66,11 +42,22 @@
self.bodyLabel.text = body;
}
////////////////////////////////////////////////////////////////////////////////
//
// Actions
//
////////////////////////////////////////////////////////////////////////////////
- (id)initWithUserInfo:(NSDictionary *)userInfo {
self = [super initWithNibName:@"NotificationDetail" bundle:nil];
if (self) {
_userInfo = userInfo;
}
return self;
}
- (void)viewDidLayoutSubviews {
//
// Workaround the fact that UILabel doesn't support top-left aligned text.
// Instead resize the control to fit the specified text.
//
[self.titleLabel sizeToFit];
[self.bodyLabel sizeToFit];
}
- (IBAction)handleDismiss:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];

Просмотреть файл

@ -2,5 +2,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import "SBNotificationHub.h"
#import "SBConnectionString.h"
#import <UIKit/UIKit.h>
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>
@property (strong, nonatomic) UIWindow * window;
@end

Просмотреть файл

@ -0,0 +1,54 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import "SceneDelegate.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
}
- (void)sceneDidDisconnect:(UIScene *)scene {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
}
- (void)sceneDidBecomeActive:(UIScene *)scene {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
- (void)sceneWillResignActive:(UIScene *)scene {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
- (void)sceneWillEnterForeground:(UIScene *)scene {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
- (void)sceneDidEnterBackground:(UIScene *)scene {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
@end

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 18 KiB

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Просмотреть файл

@ -0,0 +1,40 @@
#include "../../../Config/App.xcconfig"
IPHONEOS_DEPLOYMENT_TARGET = 13.1
PRODUCT_NAME = SampleNHAppObjC
PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.$(PRODUCT_NAME)
INFOPLIST_FILE = $(PRODUCT_NAME)/Info.plist
CODE_SIGN_ENTITLEMENTS = $(PRODUCT_NAME)/$(PRODUCT_NAME).entitlements
ARCHS[sdk=iphoneos*] = $(ARCHS_STANDARD) arm64e
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
ALWAYS_SEARCH_USER_PATHS = NO
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
DEFINES_MODULE = NO
ENABLE_NS_ASSERTIONS = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
MTL_ENABLE_DEBUG_INFO = NO
PRODUCT_NAME = $(TARGET_NAME)
VALIDATE_PRODUCT = YES
SDKROOT = iphoneos
TARGETED_DEVICE_FAMILY = 1,2
FRAMEWORK_SEARCH_PATHS = $(PROJECT_DIR)/../WindowsAzureMessaging-SDK-Apple/iOS/**
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CLANG_ANALYZER_NONNULL = YES
CLANG_CXX_LANGUAGE_STANDARD = gnu++14
CLANG_CXX_LIBRARY = libc++
CLANG_ENABLE_MODULES = YES
CLANG_ENABLE_OBJC_ARC = YES
GCC_C_LANGUAGE_STANDARD = gnu99
GCC_DYNAMIC_NO_PIC = NO
GCC_NO_COMMON_BLOCKS = YES
DEVELOPMENT_TEAM = S4V3D7CHJR

Просмотреть файл

@ -1,11 +1,8 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import <UIKit/UIKit.h>
#import <WindowsAzureMessaging/WindowsAzureMessaging.h>
#import <UserNotifications/UserNotifications.h>
@interface ViewController : UIViewController

Просмотреть файл

@ -1,11 +1,10 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import "ViewController.h"
#import "Constants.h"
#import "AppDelegate.h"
#import "Constants.h"
@interface ViewController ()
@ -13,37 +12,21 @@
@implementation ViewController
////////////////////////////////////////////////////////////////////////////////
//
// UIViewController methods
//
////////////////////////////////////////////////////////////////////////////////
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
// Simple method to dismiss keyboard when user taps outside of the UITextField.
[self.view endEditing:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Load raw tags text from storage and initialize the text field
self.tagsTextField.text = [[NSUserDefaults standardUserDefaults] valueForKey:NHUserDefaultTags];
}
////////////////////////////////////////////////////////////////////////////////
//
// Actions
//
////////////////////////////////////////////////////////////////////////////////
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}
- (IBAction)handleRegister:(id)sender {
// Save raw tags text in storage
[[NSUserDefaults standardUserDefaults] setValue:self.tagsTextField.text forKey:NHUserDefaultTags];
//
// Delegate processing the register action to the app delegate.
//
[[[UIApplication sharedApplication] delegate] performSelector:@selector(handleRegister)];
}

Просмотреть файл

@ -1,7 +1,6 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

Просмотреть файл

@ -0,0 +1,266 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
4C1C0EBA24D864240019A46B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0EB924D864240019A46B /* AppDelegate.swift */; };
4C1C0EBC24D864240019A46B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0EBB24D864240019A46B /* SceneDelegate.swift */; };
4C1C0EBE24D864240019A46B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0EBD24D864240019A46B /* ViewController.swift */; };
4C1C0EC124D864240019A46B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0EBF24D864240019A46B /* Main.storyboard */; };
4C1C0EC324D864250019A46B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0EC224D864250019A46B /* Assets.xcassets */; };
4C1C0EC624D864250019A46B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0EC424D864250019A46B /* LaunchScreen.storyboard */; };
4C1C0ECE24D8647E0019A46B /* DevSettings.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0ECD24D8647E0019A46B /* DevSettings.plist */; };
4C1C0ED224D87F470019A46B /* WindowsAzureMessaging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1C0ED124D87F470019A46B /* WindowsAzureMessaging.framework */; };
4C1C0ED424D880110019A46B /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0ED324D880110019A46B /* Utils.swift */; };
4C1C0ED624D882440019A46B /* NotificationDetail.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0ED524D882440019A46B /* NotificationDetail.xib */; };
4C1C0ED824D8828D0019A46B /* NotificationDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C0ED724D8828D0019A46B /* NotificationDetailViewController.swift */; };
4C1C0EDA24D8865C0019A46B /* Splash.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C1C0ED924D8865C0019A46B /* Splash.png */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
4C1C0EB624D864240019A46B /* SampleNHAppLegacySwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleNHAppLegacySwift.app; sourceTree = BUILT_PRODUCTS_DIR; };
4C1C0EB924D864240019A46B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4C1C0EBB24D864240019A46B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
4C1C0EBD24D864240019A46B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
4C1C0EC024D864240019A46B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4C1C0EC224D864250019A46B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4C1C0EC524D864250019A46B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4C1C0EC724D864250019A46B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4C1C0ECD24D8647E0019A46B /* DevSettings.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = DevSettings.plist; sourceTree = "<group>"; };
4C1C0ECF24D879AF0019A46B /* SampleNHAppLegacySwift.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SampleNHAppLegacySwift.entitlements; sourceTree = "<group>"; };
4C1C0ED124D87F470019A46B /* WindowsAzureMessaging.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WindowsAzureMessaging.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4C1C0ED324D880110019A46B /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
4C1C0ED524D882440019A46B /* NotificationDetail.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NotificationDetail.xib; sourceTree = "<group>"; };
4C1C0ED724D8828D0019A46B /* NotificationDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationDetailViewController.swift; sourceTree = "<group>"; };
4C1C0ED924D8865C0019A46B /* Splash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Splash.png; sourceTree = "<group>"; };
4C1C0EE224D889250019A46B /* SampleNHApp.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SampleNHApp.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4C1C0EB324D864240019A46B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4C1C0ED224D87F470019A46B /* WindowsAzureMessaging.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4C1C0EAD24D864240019A46B = {
isa = PBXGroup;
children = (
4C1C0EB824D864240019A46B /* SampleNHAppLegacySwift */,
4C1C0EB724D864240019A46B /* Products */,
4C1C0ED024D87F470019A46B /* Frameworks */,
);
sourceTree = "<group>";
};
4C1C0EB724D864240019A46B /* Products */ = {
isa = PBXGroup;
children = (
4C1C0EB624D864240019A46B /* SampleNHAppLegacySwift.app */,
);
name = Products;
sourceTree = "<group>";
};
4C1C0EB824D864240019A46B /* SampleNHAppLegacySwift */ = {
isa = PBXGroup;
children = (
4C1C0EE024D888A30019A46B /* Support */,
4C1C0EC224D864250019A46B /* Assets.xcassets */,
4C1C0ECF24D879AF0019A46B /* SampleNHAppLegacySwift.entitlements */,
4C1C0EB924D864240019A46B /* AppDelegate.swift */,
4C1C0EC424D864250019A46B /* LaunchScreen.storyboard */,
4C1C0EBF24D864240019A46B /* Main.storyboard */,
4C1C0ED524D882440019A46B /* NotificationDetail.xib */,
4C1C0ED724D8828D0019A46B /* NotificationDetailViewController.swift */,
4C1C0EBB24D864240019A46B /* SceneDelegate.swift */,
4C1C0ED324D880110019A46B /* Utils.swift */,
4C1C0EBD24D864240019A46B /* ViewController.swift */,
4C1C0ECD24D8647E0019A46B /* DevSettings.plist */,
4C1C0EC724D864250019A46B /* Info.plist */,
4C1C0ED924D8865C0019A46B /* Splash.png */,
);
path = SampleNHAppLegacySwift;
sourceTree = "<group>";
};
4C1C0ED024D87F470019A46B /* Frameworks */ = {
isa = PBXGroup;
children = (
4C1C0ED124D87F470019A46B /* WindowsAzureMessaging.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
4C1C0EE024D888A30019A46B /* Support */ = {
isa = PBXGroup;
children = (
4C1C0EE224D889250019A46B /* SampleNHApp.xcconfig */,
);
path = Support;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
4C1C0EB524D864240019A46B /* SampleNHAppLegacySwift */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4C1C0ECA24D864250019A46B /* Build configuration list for PBXNativeTarget "SampleNHAppLegacySwift" */;
buildPhases = (
4C1C0EB224D864240019A46B /* Sources */,
4C1C0EB324D864240019A46B /* Frameworks */,
4C1C0EB424D864240019A46B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = SampleNHAppLegacySwift;
productName = SampleNHAppLegacySwift;
productReference = 4C1C0EB624D864240019A46B /* SampleNHAppLegacySwift.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
4C1C0EAE24D864240019A46B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1160;
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = Microsoft;
TargetAttributes = {
4C1C0EB524D864240019A46B = {
CreatedOnToolsVersion = 11.6;
};
};
};
buildConfigurationList = 4C1C0EB124D864240019A46B /* Build configuration list for PBXProject "SampleNHAppLegacySwift" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 4C1C0EAD24D864240019A46B;
productRefGroup = 4C1C0EB724D864240019A46B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
4C1C0EB524D864240019A46B /* SampleNHAppLegacySwift */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
4C1C0EB424D864240019A46B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C1C0ED624D882440019A46B /* NotificationDetail.xib in Resources */,
4C1C0EC624D864250019A46B /* LaunchScreen.storyboard in Resources */,
4C1C0EC324D864250019A46B /* Assets.xcassets in Resources */,
4C1C0EC124D864240019A46B /* Main.storyboard in Resources */,
4C1C0EDA24D8865C0019A46B /* Splash.png in Resources */,
4C1C0ECE24D8647E0019A46B /* DevSettings.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
4C1C0EB224D864240019A46B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C1C0EBE24D864240019A46B /* ViewController.swift in Sources */,
4C1C0EBA24D864240019A46B /* AppDelegate.swift in Sources */,
4C1C0EBC24D864240019A46B /* SceneDelegate.swift in Sources */,
4C1C0ED424D880110019A46B /* Utils.swift in Sources */,
4C1C0ED824D8828D0019A46B /* NotificationDetailViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
4C1C0EBF24D864240019A46B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
4C1C0EC024D864240019A46B /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
4C1C0EC424D864250019A46B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
4C1C0EC524D864250019A46B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
4C1C0EC824D864250019A46B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4C1C0EE224D889250019A46B /* SampleNHApp.xcconfig */;
buildSettings = {
ENABLE_TESTABILITY = YES;
};
name = Debug;
};
4C1C0EC924D864250019A46B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4C1C0EE224D889250019A46B /* SampleNHApp.xcconfig */;
buildSettings = {
};
name = Release;
};
4C1C0ECB24D864250019A46B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
};
name = Debug;
};
4C1C0ECC24D864250019A46B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
4C1C0EB124D864240019A46B /* Build configuration list for PBXProject "SampleNHAppLegacySwift" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4C1C0EC824D864250019A46B /* Debug */,
4C1C0EC924D864250019A46B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4C1C0ECA24D864250019A46B /* Build configuration list for PBXNativeTarget "SampleNHAppLegacySwift" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4C1C0ECB24D864250019A46B /* Debug */,
4C1C0ECC24D864250019A46B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 4C1C0EAE24D864240019A46B /* Project object */;
}

Просмотреть файл

@ -1,7 +1,6 @@
//
// Copyright © 2018 Microsoft All rights reserved.
// Licensed under the Apache License (2.0).
//
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
import UIKit
import UserNotifications
@ -9,10 +8,9 @@ import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
// MARK: UIApplicationDelegate Methods
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UNUserNotificationCenter.current().delegate = self
return true
}
@ -47,9 +45,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
logNotificationDetails(userInfo);
completionHandler(UIBackgroundFetchResult.newData);
}
// MARK: UNUserNotificationCenterDelegate Methods
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
@ -70,28 +69,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
completionHandler()
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
func logNotificationDetails(_ userInfo: Any) {
let state = UIApplication.shared.applicationState;
let background = state != .active;
@ -104,5 +96,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
let notificationDetail = NotificationDetailViewController(userInfo)
UIApplication.shared.keyWindow?.rootViewController?.present(notificationDetail, animated: true, completion: nil)
}
}

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 441 B

После

Ширина:  |  Высота:  |  Размер: 441 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 772 B

После

Ширина:  |  Высота:  |  Размер: 772 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.0 KiB

После

Ширина:  |  Высота:  |  Размер: 1.0 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 598 B

После

Ширина:  |  Высота:  |  Размер: 598 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 992 B

После

Ширина:  |  Высота:  |  Размер: 992 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.3 KiB

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 772 B

После

Ширина:  |  Высота:  |  Размер: 772 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.3 KiB

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.7 KiB

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 991 B

После

Ширина:  |  Высота:  |  Размер: 991 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.7 KiB

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.5 KiB

После

Ширина:  |  Высота:  |  Размер: 2.5 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.1 KiB

После

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.2 KiB

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.3 KiB

После

Ширина:  |  Высота:  |  Размер: 2.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 916 B

После

Ширина:  |  Высота:  |  Размер: 916 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.5 KiB

После

Ширина:  |  Высота:  |  Размер: 1.5 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 14 KiB

После

Ширина:  |  Высота:  |  Размер: 14 KiB

Просмотреть файл

@ -0,0 +1,10 @@
<?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>HUB_NAME</key>
<string></string>
<key>CONNECTION_STRING</key>
<string></string>
</dict>
</plist>

Просмотреть файл

@ -4,8 +4,6 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>NH Sample</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@ -15,17 +13,32 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NotificationHubConnectionString</key>
<string>CONNECTIONSTRING</string>
<key>NotificationHubName</key>
<string>HUBNAME</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
@ -41,13 +54,15 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше