Skip to content

Commit 97c80b9

Browse files
committed
Replaced .aar and jars with PlayServicesResolver
* The Google Play services library dependencies will now be added by the PlayServicesResolver. - It will automatically include the correct .aar files (projects for Unity4.7) and prevent conflict issues with other plugins. - Tested compatibility with play-games-plugin-for-unity.
1 parent fa4c4e1 commit 97c80b9

File tree

104 files changed

+1986
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1986
-282
lines changed

LICENSE

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Modified MIT License
22

3-
Copyright 2015 OneSignal
3+
Copyright 2016 OneSignal
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -125,4 +125,20 @@ Includes ShortcutBadger:
125125
distributed under the License is distributed on an "AS IS" BASIS,
126126
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127127
See the License for the specific language governing permissions and
128-
limitations under the License.
128+
limitations under the License.
129+
130+
131+
Includes unity-jar-resolver
132+
Copyright (C) 2014 Google Inc.
133+
134+
Licensed under the Apache License, Version 2.0 (the "License");
135+
you may not use this file except in compliance with the License.
136+
You may obtain a copy of the License at
137+
138+
http://www.apache.org/licenses/LICENSE-2.0
139+
140+
Unless required by applicable law or agreed to in writing, software
141+
distributed under the License is distributed on an "AS IS" BASIS,
142+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
143+
See the License for the specific language governing permissions and
144+
limitations under the License.

Unity4.7OneSignalExample/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ Assets/Root
5353

5454
/iosbuild/
5555
/web/
56+
57+
/Assets/Plugins/Android/play-services-*
58+
/Assets/Plugins/Android/support-v4-*
59+
/Assets/Plugins/Android/support-annotations-*.jar*
60+
61+
/ProjectSettings/GoogleDependencyOneSignal.xml
62+
63+
/Assets/Plugins/Android/OneSignalConfig/AndroidManifest.xml*
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Modified MIT License
3+
*
4+
* Copyright 2016 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#if UNITY_ANDROID && UNITY_EDITOR
29+
using UnityEditor;
30+
using System.IO;
31+
using UnityEngine;
32+
33+
using Google.JarResolver;
34+
35+
[InitializeOnLoad]
36+
public class OneSignalEditorScript {
37+
38+
private static readonly string PluginName = "OneSignal";
39+
private static readonly string PLAY_SERVICES_VERSION = "9+";
40+
public static PlayServicesSupport svcSupport;
41+
42+
static OneSignalEditorScript () {
43+
createOneSignalAndroidManifest();
44+
addGMSLibrary();
45+
}
46+
47+
private static void addGMSLibrary() {
48+
svcSupport = PlayServicesSupport.CreateInstance(PluginName,
49+
EditorPrefs.GetString("AndroidSdkRoot"),
50+
"ProjectSettings");
51+
52+
svcSupport.DependOn("com.google.android.gms", "play-services-gcm", PLAY_SERVICES_VERSION);
53+
svcSupport.DependOn("com.google.android.gms", "play-services-location", PLAY_SERVICES_VERSION);
54+
// Adds play-services-base, play-services-basement, play-services-iid, and support-v4 will be automaticly added.
55+
// Also adds play-services-tasks but this isn't used by OneSignal, it just added as a depency from the above.
56+
57+
58+
// Setting 8.3+ does not work with unity-jar-resolver-1.2.0 and GooglePlayGamesPlugin-0.9.34.
59+
// It creates conflicting aar files with mismatched version of 8.4 and 9.4
60+
// svcSupport.DependOn("com.google.android.gms", "play-services-gcm", "8.3+");
61+
// svcSupport.DependOn("com.google.android.gms", "play-services-location", "8.3+");
62+
// play-services-base, play-services-basement, and support-v4 will be automaticly added.
63+
// play-services-maps and play-services-measurement are not used by OneSignal
64+
// but are included as depencies from the other parts of play-services.
65+
}
66+
67+
// Copies `AndroidManifestTemplate.xml` to `AndroidManifest.xml`
68+
// then replace `${manifestApplicationId}` with current packagename in the Unity settings.
69+
private static void createOneSignalAndroidManifest() {
70+
string oneSignalConfigPath = "Assets/Plugins/Android/OneSignalConfig/";
71+
string manifestFullPath = oneSignalConfigPath + "AndroidManifest.xml";
72+
73+
File.Copy(oneSignalConfigPath + "AndroidManifestTemplate.xml", manifestFullPath, true);
74+
75+
StreamReader streamReader = new StreamReader(manifestFullPath);
76+
string body = streamReader.ReadToEnd();
77+
streamReader.Close();
78+
79+
body = body.Replace("${manifestApplicationId}", PlayerSettings.bundleIdentifier);
80+
using (var streamWriter = new StreamWriter(manifestFullPath, false))
81+
{
82+
streamWriter.Write(body);
83+
}
84+
}
85+
}
86+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.16.0
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity4.7OneSignalExample/Assets/PlayServicesResolver/Editor.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)