نقل البيانات إلى الإصدار 4 من حزمة تطوير البرامج (SDK) لمشرف Go
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بدءًا من الإصدار 4.0.0، تم تفعيل Firebase Admin SDK في Go
لوحدات Go. بالإضافة إلى ذلك، هناك تغييرات غير متوافقة مع الإصدارات السابقة في التعامل مع الأخطاء والدلالات.
التغييرات في عمليات التثبيت
وفقًا لأفضل الممارسات المتعلّقة بالوحدات،
تمت إضافة الإصدار الرئيسي من حزمة SDK إلى اسم الحزمة. يؤدي هذا التغيير إلى تعديل أسماء الحِزم على النحو التالي:
لتثبيت إصدار سابق، استخدِم اسم الحزمة القديم (غير المرتبط بإصدار) مع
محدد إصدار صريح.
# Notice the @v3 suffix.# This instructs Go tools to fetch the latest v3.x release of the SDK.gogetfirebase.google.com/go@v3
المطوّرون الذين لا يستخدمون الوحدات حاليًا
يمكن للمطوّرين الذين لم يفعّلوا الوحدات بعد مواصلة تثبيت حزمة SDK
باستخدام اسم الحزمة غير المحدّد الإصدار.
gogetfirebase.google.com/go
يُرجى العِلم أنّ هذا الإجراء يجلب أحدث إصدار من حزمة SDK (الإصدار 4 أو إصدار أحدث)
الذي يتضمّن تغييرات أخرى غير متوافقة في واجهة برمجة التطبيقات.
التغييرات العامة في معالجة الأخطاء
تقدّم حزمة تطوير البرامج (SDK) الإصدار 4 حزمة errorutils جديدة توفّر وظائف للتعامل مع حالات الخطأ على مستوى النظام الأساسي. في حال حدوث خطأ بسبب خطأ في إحدى الخدمات الخلفية، يمكنك الوصول إلى استجابة الخطأ الأصلية من خلال استدعاء الدالة الجديدة errorutils.HTTPResponse(). يمكنك استخدام الدوال في هذه الحزمة مع الأخطاء التي تعرضها أي واجهة برمجة تطبيقات في حزمة SDK.
Authentication التغييرات في واجهة برمجة التطبيقات
تمت إضافة وظائف جديدة لمعالجة الأخطاء لاستخدامها مع واجهتَي برمجة التطبيقات VerifyIDToken() وVerifySessionCookie():
IsIDTokenInvalid()
IsIDTokenExpired()
IsSessionCookieInvalid()
IsSessionCookieExpired()
IsCertificateFetchFailed()
تم إيقافها نهائيًا:
IsProjectNotFound()
IsUnknown()
IsInsufficientPermission()
IsInvalidEmail()
FCM التغييرات في واجهة برمجة التطبيقات
تمت إعادة تسمية النوع messaging.WebpushFCMOptions إلى messaging.WebpushFcmOptions.
تمت إضافة:
IsThirdPartyAuthError()
IsQuotaExceeded()
IsSenderIDMismatch()
IsUnregistered()
IsUnavailable()
تم إيقافها نهائيًا:
IsInvalidAPNSCredentials()
IsMessageRateExceeded()
IsMismatchedCredential()
IsRegistrationTokenNotRegistered()
IsServerUnavailable()
IsTooManyTopics()
IsUnknown()
التغييرات في واجهة برمجة التطبيقات IID
تم الآن إيقاف جميع وظائف معالجة الأخطاء المتوفّرة حاليًا في حزمة iid. استخدِم دوال معالجة الأخطاء المناسبة المتوفّرة في الحزمة
errorutils بدلاً من ذلك.
تاريخ التعديل الأخير: 2025-08-01 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-01 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["\u003cbr /\u003e\n\nStarting from version 4.0.0, the Firebase Admin SDK for Go has opted into\n[Go modules](https://github.com/golang/go/wiki/Modules). Also, there are breaking\nchanges in [error handling](/docs/reference/admin/error-handling) and semantics.\n\nInstallation changes\n\nConforming to [modules best practices](https://github.com/golang/go/wiki/Modules#semantic-import-versioning),\nthe SDK's major version has been appended to the package name. This\nchange results in the following package name updates:\n\n- firebase.google.com/go → firebase.google.com/go/v4\n- firebase.google.com/go/auth → firebase.google.com/go/v4/auth\n- firebase.google.com/go/db → firebase.google.com/go/v4/db\n- firebase.google.com/go/iid → firebase.google.com/go/v4/iid\n- firebase.google.com/go/messaging → firebase.google.com/go/v4/messaging\n\n| **Note:** Developers who are already using Go modules **must** use the new versioned package name when installing and importing the SDK.\n\nDevelopers already using modules\n\nUse the versioned package name to install the latest version of the SDK. \n\n # Install the latest version:\n go install firebase.google.com/go/v4@latest\n\n # Or install a specific version:\n go install firebase.google.com/go/v4@4.18.0\n\nThe same versioned package name must be used in the source code when importing\nthe SDK. \n\n package helloworld\n\n import (\n \"firebase.google.com/go/v4\"\n \"firebase.google.com/go/v4/auth\"\n \"firebase.google.com/go/v4/messaging\"\n )\n\nTo install an earlier version, use the old (unversioned) package name with an\nexplicit version qualifier. \n\n # Notice the @v3 suffix.\n # This instructs Go tools to fetch the latest v3.x release of the SDK.\n go get firebase.google.com/go@v3\n\nDevelopers not currently using modules\n\nDevelopers who haven't opted into modules yet can continue to install the SDK\nusing the unversioned package name. \n\n go get firebase.google.com/go\n\nNote, however, that this fetches the latest version of the SDK (v4 or later)\nwhich contains other breaking API changes.\n\nGeneral error handling changes\n\nThe v4 SDK introduces a new `errorutils` package that provides functions for\nhandling platform-level error conditions. In the event an error was caused by a\nbackend service error, you can access the original error response by calling\nthe new function `errorutils.HTTPResponse()`. You can use the functions in\nthis package with errors returned by any API in the SDK.\n\nAuthentication API changes\n\n- Added new error handling functions to be used in conjunction with `VerifyIDToken()` and `VerifySessionCookie()` APIs:\n - `IsIDTokenInvalid()`\n - `IsIDTokenExpired()`\n - `IsSessionCookieInvalid()`\n - `IsSessionCookieExpired()`\n - `IsCertificateFetchFailed()`\n- Deprecated:\n - `IsProjectNotFound()`\n - `IsUnknown()`\n - `IsInsufficientPermission()`\n - `IsInvalidEmail()`\n\nFCM API changes\n\n- Renamed the type `messaging.WebpushFCMOptions` to `messaging.WebpushFcmOptions`.\n- Added:\n - `IsThirdPartyAuthError()`\n - `IsQuotaExceeded()`\n - `IsSenderIDMismatch()`\n - `IsUnregistered()`\n - `IsUnavailable()`\n- Deprecated:\n - `IsInvalidAPNSCredentials()`\n - `IsMessageRateExceeded()`\n - `IsMismatchedCredential()`\n - `IsRegistrationTokenNotRegistered()`\n - `IsServerUnavailable()`\n - `IsTooManyTopics()`\n - `IsUnknown()`\n\nIID API changes\n\nAll error handling functions currently available in the `iid` package are now\ndeprecated. Use the corresponding error handling functions provided in the\n`errorutils` package instead."]]